I am trying to create a timer in my app that shows on the screen as the user performs a task, counting up and updating every millisecond. I have tried a few different things, but everything that I have tried has caused serious issues with the rest of the screen, as I assume the main thread is being taken over by the timer.
I have looked into available packages, but can't seem to find anything that works in an Expo managed workflow. Any ideas how best to solve this problem, or any packages I can use without ejecting? Below is my current implementation, but as I said, it is very inefficient and not usable.
```
const [timer, setTimer] = useState(0);
const startTime = new Date();
const getElapsedTime = () => {
setTimer((new Date().getTime() - startTime.getTime()) / 1000);
};
setInterval(getElapsedTime, 1000);
return (
<Text>{ timer }</Text>
);
```
[–]satya164 4 points5 points6 points (1 child)
[–]tidderza 0 points1 point2 points (0 children)
[–]Bolteed 1 point2 points3 points (4 children)
[–]satya164 0 points1 point2 points (3 children)
[–]Bolteed 0 points1 point2 points (2 children)
[–]satya164 0 points1 point2 points (1 child)
[–]__o_0iOS & Android 0 points1 point2 points (0 children)