Is the below code correct when useEffect has a condition setTimout?
useEffect(() => {
if (condition) {
const timer = setTimeout(() => {
func1()
}, 1000)
return () => {
clearTimeout(timer)
}
}
func2()
return () => {}
}, [])