setInterval without destroying it to update state?
I have a perdicament where I want to update state on an interval. Every way that I go about it I find myself being forced to use the dependency array of the useEffect for the setInterval so I can get updated state values. This causes my interval to just be destroyed and rebuilt every interval because of state changing on the interval.
How can I achieve this interval without ever having to destroy it to listen to state changes?
Solution:Jump to solution
Looks like the answer I'm looking for is to not read state at all and instead use local values.
2 Replies
Solution
Looks like the answer I'm looking for is to not read state at all and instead use local values.
or read
someRef.current
from inside an interval