0

REACT Code Error

I want to Make a timer . on start button timer started and incrementing the value works correctly. But I want to pause the timer I make a function but It gives me error on line no 16 https://www.sololearn.com/post/334673/?ref=app https://www.sololearn.com/post/334674/?ref=app

18th Apr 2020, 2:01 PM
Saad Saleem
Saad Saleem - avatar
5 Answers
+ 6
Hard for me to go on without knowing the error, tho my guess is that the onstop function is not binded to the class (the onstart function is an arrow function so it automatically gets binded) Also, if you can re-create the code on sololearn it will be much easier if i can play around with it. You can use this template: https://code.sololearn.com/Wi772Mr81mX8/?ref=app
18th Apr 2020, 2:07 PM
Burey
Burey - avatar
+ 4
Oy I totally missed that Calviղ 😅
18th Apr 2020, 5:17 PM
Burey
Burey - avatar
+ 2
clearInterval(this.clearInterval)
18th Apr 2020, 3:55 PM
CalviŐ˛
CalviŐ˛ - avatar
18th Apr 2020, 2:03 PM
Saad Saleem
Saad Saleem - avatar
0
Burey thanks it's working I forget to bind the stop function I already added clearInterval method in componentwillmount but after I add CleartimeOut in stop method my code working to expectations
18th Apr 2020, 9:04 PM
Saad Saleem
Saad Saleem - avatar