I need to convert an arrow function into a function. This is due to a problem with Slick Slider, as it does not support properly arrow functions.
I have convert this:
beforeChange={(current, next) => this.setState({slideIndex: next})}
Into this:
beforeChange={function(current, next) {
this.setState({slideIndex: next});
}}
But does not work. Already tried this solution:
beforeChange={function(current, next) {
this.setState(function() {
return {slideIndex: next};
});
}}
thisscope is wrong. When using arrow function (=>)thisremains, but when usingfunction(){},thishas it's own scope, sothis.setState()will not work, unless you bind the function with...}.bind(this)