Skip to content

How is onScriptLoaded intended to be used? #37

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

Open
petervijeh opened this issue Jan 11, 2019 · 1 comment
Open

How is onScriptLoaded intended to be used? #37

petervijeh opened this issue Jan 11, 2019 · 1 comment

Comments

@petervijeh
Copy link

Not clear how this method is used, are there any examples anywhere?

@AndrewLowther
Copy link

@petervijeh As I understand it, it's meant to be passed down as a prop by parent components as necessary.

import MyAsyncComponent from 'components/MyAsyncComponent';

const onScriptLoaded = () => {
   // Run code that is dependant on the script being loaded.
  let script = window.loadedScript;
  script.run('foo', bar);
};

return () => <MyAsyncComponent onScriptLoaded={onScriptLoaded} />

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

2 participants