I have the following useEffect:
useEffect(() => {
const closeFeedbackTimer = setTimeout(() => {
console.log('test')
}, 5000)
if (!finishedFeedbackOpen) {
clearTimeout(closeFeedbackTimer)
}
}, [finishedFeedbackOpen])
And finishedFeedbackOpen is set to true/false with a function inside my component.
The problem is: when finishedFeedbackOpen is set to false, the timeout is not cleared, even if entering the if condition.