I am facing a problem when the app is running the timer is working correctly however when I reset the timer the countdown timer is stuck in the initial state.
const [timer, setTimer] = useState(30)
useEffect(() => {
let interval = setInterval(() => {
setTimer(prev => {
if (prev === 1) clearInterval(interval)
return prev - 1
})
}, 1000)
newQuestion()
return () => clearInterval(interval)
}, [])
const handleReset = () => {
setTimer(30)
setScore(0)
}