Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://hookstate.js.org/docs/exceptions/#hookstate-106 is killing me #389

Open
dioptre opened this issue Apr 28, 2023 · 1 comment
Open

Comments

@dioptre
Copy link

dioptre commented Apr 28, 2023

Hi & thanks for the great product!

Imagine a world where there is a top level hookstate object in react that is created on component instantiation, then theres asyncs on asyncs that exist that reference that object.

When you click back and forward on the page, the async operation would be completed - but the hookstate object is no longer there, and the error is so bad try/catch doesn't always work.

Now imagine a world where get/set access was managed via events, signals and AbortControllers.
Ex. https://stackoverflow.com/questions/30233302/promise-is-it-possible-to-force-cancel-a-promise

What would it feel like if it were integrated into the hookstate object for easy access?

Would be interested in discussing...

@avkonst
Copy link
Owner

avkonst commented Apr 29, 2023

Clean design assumes you are killing async operations on component unmount. Otherwise you risk leakage of objects and resources. React itself prints warnings to console for usestate if you do not do it. Hookstate raises an exception but can be converted to a warning too. I am fan of strict phylosophy but perhaps we can make this behavior globally configurable via configure function. Would you be able to create a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants