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

How to *not* load a script if it's already loaded...

Open kimfucious opened this issue 5 years ago • 0 comments

Working on an React App, trying to get Paypal SDK to work.

The initial load works fine, but if the user navigates away from the page and back, things fail:

Error: Expected element to be passed to render iframe

How can you conditionally load the script, so that it's only loaded once based on the existence of window.paypal?

I've tried various conditionals in handleScriptCreate and handleScriptLoad, but I've not found the secret sauce.

Any advice would be appreciated.

kimfucious avatar Aug 01 '20 13:08 kimfucious