Skip to content

Dynamic script urls (from props) #29

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
cdelaorden opened this issue Jan 12, 2018 · 3 comments
Open

Dynamic script urls (from props) #29

cdelaorden opened this issue Jan 12, 2018 · 3 comments

Comments

@cdelaorden
Copy link

This library is pretty useful as it is, but having the option to dynamically generate the script URLs based on props would make it more generic.

Example use case: you want to load an API library (say Google API) but want to dynamically inject the API_KEY based on config fetched from server, or logged in user permissions/profile, and so on.

Basically being able to do something like:

const Enhanced = AsyncScriptLoader(props => {
  return [
          'https://ajax.googleapis.com/ajax/libs/jquery/' +
            props.version +
            '/jquery.min.js'        
  ]
})(MyComponent)

// later on
<MyComponent version='3.0.0' />

In addition this will make this library play much nicer with recompose in which a stream of props is generated from HOC to HOC.

Pull request to follow :)

@manelet
Copy link

manelet commented Feb 13, 2018

Hey! I'm also looking for a way to use props to dynamically create URLs.

Will this be merged or is there any way to achieve the same result?

Thanks in advance!

@dgana
Copy link

dgana commented Mar 17, 2019

has this been resolved? I need it also to create dynamic URL for apiKey.
can this resolve the issue --> https://stackoverflow.com/questions/43351122/building-a-component-which-depends-on-a-3rd-party-script

Thanks anyway for the amazing library!

@annshress
Copy link

annshress commented Sep 9, 2019

Any updates regarding this? Or are there any workarounds?

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

4 participants