I'm sure this is rather simple, but with me being new to JS and React I can't seem to find an answer to this.
Basically, I have a function that uses the JQ animate method to act as a counter of sorts. The function looks like this:
$({countNum: 99}).animate({countNum: 1000}, {
duration: 2000,
easing:'linear',
step: function() {
var counter = Math.floor(this.countNum)
console.log(counter)
},
complete: function() {
return 'counter done';
}
});
I am trying to setState within the step so that I can simulate a counter on my app as it counts up to a specific number. In order to set the state I need to bind this to the object in the animate function, however then I can't figure out how to access the countNum so that it increases.
Any ideas? Or am I approaching this totally wrong.