useEffect(() => {
let interval = null;
if (isActive) {
document.title = `${seconds} seconds`;
interval = setInterval(() => {
setSeconds((seconds) => seconds + 1);
}, 1000);
} else if (!isActive && seconds != 0) {
document.title = `React App`;
clearInterval(interval);
}
return () => clearInterval(interval);
}, [isActive, seconds]);
Why the interval variable assigned to null in the first line of the useEffect hook?