Javascript – React: settimeout's callback doesn't have updated state value
I want to call a function at regular intervals and update state inside it. I started with a useEffect but eventually ended up here. I tried using Ref.current to store the interval and clear it every time in the function…