made a caching method in my react notepad and came up to a minor bug, I used useEffect to set an interval of 3 seconds then updates the cache holder if the heading and description is not false although when it starts to run and either of the heading or description changes back to false(empty or invalid value) the interval doesn’t recognised the updates
when it starts to run it does not stops back then even though the heading or description has emptied which has to set the interval condition to false
let [heading, setHeading] = useState(addTextCache.heading)
let [description, setDescription] = useState(addTextCache.description)
useEffect(() => {
let count = 0
setInterval(() => {
if(heading != false && description != false) {
count++
console.log(count)
console.log(heading != false && description != false)
setAddTextCache({
heading: heading,
description: description
})
}
}, 3000)
}, [heading, description])