react-use-external-assets
Append multiple scripts and stylesheets to the document body as functions
Install
npm install --save react-use-external-assets
Usage
import { useExternalScripts } from 'react-use-external-assets'
const Example = () => {
const loadState = useExternalScripts([
'https://my-domain.com/my-script.js'
])
return (
<div>
{Object.values(loadState).every(s => s === 'ready') ? 'Everything is ready!' : 'Getting things ready...'}
</div>
)
}
License
MIT © wimoMisterX
This hook is created using create-react-hook.