react-script-hook icon indicating copy to clipboard operation
react-script-hook copied to clipboard

Value of `load` never changes

Open allroundexperts opened this issue 3 years ago • 2 comments

We're facing an issue where if the hook un-mounts before the onload handler being called, the value of load remains true indefinitely. This makes sense if you read through the code as well.

If the component un-mounts before the handler given here gets called: https://github.com/hupe1980/react-script-hook/blob/master/src/use-script.tsx#L111 then the load value will always remain true even on subsequent mounts because the script has been loaded and we removed the event listener for load before it could be fired. This is causing our E2E tests to break intermittently.

allroundexperts avatar Nov 03 '22 15:11 allroundexperts

Also experiencing this same issue

jonsadka avatar Dec 06 '22 17:12 jonsadka

@allroundexperts or @jonsadka do you guys have some code where I can easily reproduce this issue?

It seems react-script-hook is largely an unmaintained library, I am open to migrating the code to use something else but will need to make sure we have a way to test it works.

PC98 avatar Jul 11 '23 17:07 PC98