I'm trying to setup a progress bar for a backend action that can take a while to complete.
- User click button to export a file
- API response has a token for the backend process
- With useInterval, I check every half a second the progress % (with another endpoint, sending the token) to update my progress bar component
I simplified the code in Codesandbox to reproduce the problem, in my Codesandbox, when clicking the button, I run useInterval to get a new random cat picture every 4 seconds and update my hook.
As I understand, the problem is because I'm calling a Hook inside a custom Hook (useInterval), but I don't know another way to do this because native setInterval does not work with Hooks.
I used the use-interval package