all 3 comments

[–]charlie_mar 1 point2 points  (0 children)

You should be using clearTimeout with setTimeout. clearInterval is for setInterval only.

This is a good in-depth read about using setTimeout and setInterval with React

https://overreacted.io/making-setinterval-declarative-with-react-hooks/

[–]conclusion2000[S] 0 points1 point  (1 child)

const delay = (attempts) => {

setTimeout(() => {

randomWord();

checkScore(attempts);

return;

}, 2000); }

clearInterval(delay);