REACT Code Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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
Mr Robot
Mr Robot - 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
Mr Robot
Mr Robot - 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
Mr Robot
Mr Robot - avatar