blueberryapps / react-load-script

React component that makes it easy to load 3rd party scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Re-rendering script

bibogdanov opened this issue · comments

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 ?

@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.

+1

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

@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.

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

@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...?

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

@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...?