I want to call some function and update state after a time interval in react component but it is not working as expected. Here is my code.
componentDidUpdate(){
console.log("update")
setInterval(this.tickingTimer(), 2000)
}
tickingTimer(){
this.state.counter = this.state.counter+1
console.log("timer");
}
I tried to set interval function in componentDidMount also but it only call once. It is not updating data after interval.