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

Re-rendering script #1

Closed
bibogdanov opened this issue Aug 10, 2016 · 7 comments
Closed

Re-rendering script #1

bibogdanov opened this issue Aug 10, 2016 · 7 comments

Comments

@bibogdanov
Copy link

Hello,

I'm new to react and I'm using react-load-script for rendering a bokeh Chart served by my python (flask/pandas/bokeh) server.
I'm able to load a first script and display a chart given some arguments but when I change the arguments and try to re render nothing happens.

Do you know how to handle this problem ?

@jakubkottnauer
Copy link
Contributor

@bibogdanov Hi, most of what this component does happens in componentDidMount, which is only called once - when the component is mounted. That is why, when you pass a different set of props, nothing happens. Currently, the only solution would be to render another react-load-script component, instead of just changing the url prop.

If supporting this is something more people would like or if it proved to be necessary, I can add this functionality.

@Bartozzz
Copy link

+1

This would be a very usefull feature. Personally, I need this to implement PayU Express Widget. Maybe #5 could resolve this?

@jedwards1211
Copy link

jedwards1211 commented Aug 10, 2018

@bibogdanov @Bartozzz I just made my own package for this...cause it looks like PRs to this package aren't gonna get merged anytime soon :trollface:
https://github.com/jcoreio/react-render-props-script-loader
It supports the src prop changing, and additionally, it passes the state to a child function, so you don't have to bother with storing state in your own code :)
One downside: my package makes less effort to be compatible with old React versions, and it depends on babel-runtime if you're using it in legacy browsers.

@usamamashkoor
Copy link

@jakubkottnauer how can i add a component dynamically for loading the script again..?

@usamamashkoor
Copy link

@jedwards1211 how can i re render the google maps script again using your package because the documentation is very less in terms of this part...?

@jedwards1211
Copy link

If you change the src prop to another script, my package will load that new script

@usamamashkoor
Copy link

@jedwards1211 i am facing this issue I have created progressive web app and I am using google maps so in offline mode when there is no internet then the google maps do not load but when the internet becomes available then I want to reload that same google maps API script so that I can access the goog;e variable inside in my react component again...

Can you please help me how can I do this using your package because in my case the script is already in the dom but the google variable is not available due to the no internet and also I have the same src prop because I want to re-load the same google maps URL so how can I reload the same google script again using your package kindly help me on this please...?

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

5 participants