I have the following code in a react component:
calcTime: function() {
time = <some time dependant value>
this.setState({
total_time: time
}, window.setTimeout(this.calcTime, 1000));
}
This works fine, except that while it's running I see the following exception in the console:
Uncaught Error: Invariant Violation: enqueueCallback(...): You called
setProps,replaceProps,setState,replaceState, orforceUpdatewith a callback that isn't callable.
I did think initially that this was down to having the setTimeout function there, so I extracted that out to another function and just added that as the callback method. However, when doing this, render stopped showing the updates to the DOM.
How should I do this correctly?