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 :)
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:
In addition this will make this library play much nicer with
recomposein which a stream of props is generated from HOC to HOC.Pull request to follow :)