-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
hacktoberfestIssue designated for HacktoberfestIssue designated for Hacktoberfest
Description
As the README states, one pitfall of this hook is that it should only be called once across an entire codebase - otherwise, it will create multiple timeout interactions on the document.title
and will ruin the effect, not to mention add extra load to the browser. I'm looking for a code-based way to prevent this from occurring - perhaps by assigning an ID from the setInterval
command:
https://developer.mozilla.org/en-US/docs/Web/API/setInterval
Logic should be something like as follows:
- I would expect a setInterval ID to be saved in state (or I think a
ref
would work) - if the usePleaseStay() hook was called a second time and it was found this ID was already set, the developer should:
- in development mode, see a
new Error()
be thrown - in production mode, prevent further execution of the second calling of the hook (simply
return
from the function)
- in development mode, see a
Metadata
Metadata
Assignees
Labels
hacktoberfestIssue designated for HacktoberfestIssue designated for Hacktoberfest