well, you could set up a `stopPolling()` function inside of the `useInterval()` hook that would work similar to the `return () => clearInterval(id)` that fires now when the component calling the hook unmounts from the DOM.

This stopPolling would clear interval and set savedCallback.current = null. Then you could return `stopPolling` as another function from the hook into the component using it, and in the component, if you set a local variable like a boolean to true or false after the report's been generated, you could then call `stopPolling()` to stop it from continuing to run.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Paige Niedringhaus
Paige Niedringhaus

Written by Paige Niedringhaus

Staff Software Engineer at Blues, previously a digital marketer. Technical writer & speaker. Co-host of Front-end Fire & LogRocket podcasts

No responses yet

Write a response