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

Script not load again after react-router changes #14

Open
jpacora opened this issue Jul 19, 2017 · 6 comments
Open

Script not load again after react-router changes #14

jpacora opened this issue Jul 19, 2017 · 6 comments

Comments

@jpacora
Copy link

jpacora commented Jul 19, 2017

I have a SPA and when I go from the page who use the react-load-script component to other page and then go back to the first page the script dosn't works.

@matejlauko
Copy link

Hi. You mean the script doesn't load again, or it doesn't work at all - like it has never been loaded ?

It shouldn't load the script again when navigation through SPA (but onLoad handler is called again), but the script should work of course.

@json2d
Copy link

json2d commented Aug 15, 2017

I'm having the same issue, but I believe this is just the caveat of using react-router.

Once scripts are loaded on a page, I believe they can't be unloaded nor reloaded. Since an SPA stays on the same page, the script in question has to take this into account and work accordingly.

But if you're using a third-party script where you have no source control (like I am) it might not be possible to patch that script so that it works as you'd expect with an SPA ☹️

@jimmyspiffy
Copy link

I'm with bitstrider. The script is never unloaded if a component is unmounted. This causes certain fields to remain even if another user logs into the application.

@swaykay-foreveralearner

same problem here

@spiritwalker-jiang
Copy link

The work around I found was moving import react-load-script from top of your component file into componentDidMount hook. In this way, the script is guaranteed to be reloaded on every re-mount. Hacky though.

@spiropoulos94
Copy link

but my question is this, since the script tag is loaded on index.html file inside the public folder, and the index.html loads only once, why is it necessary to load the script on a component??

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

7 participants