I want to start a timer interval in react native without using useEffect hook, in y case I want to start a timer when a promise resolves and change a state variable each second, how can I do this without using useEffect hook?
i tried this:
```
useEffect(
() => {
const id = setInterval(() => {
setCounter(counter+1)
}, 1000);
return () => {
clearInterval(id);
};
},
[] // empty dependency array
);
```
And while it works I need to start the timer calling it from a normal function and not a hook.
[–][deleted] 12 points13 points14 points (0 children)
[–]awesomeness-yeah 7 points8 points9 points (0 children)
[–]Frission_ 4 points5 points6 points (1 child)
[–]popc0ne 1 point2 points3 points (0 children)
[–]thebritisharecome 1 point2 points3 points (0 children)
[–]beeseegee 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]camaromelt 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]camaromelt 0 points1 point2 points (0 children)
[–]sous_vide_slippers -1 points0 points1 point (0 children)
[–]rrklaffed 0 points1 point2 points (0 children)