react-use-asset-loader
v1.0.5
Published
react hook to load assets
Downloads
1
Readme
react-use-asset-loader
react hook to load assets
Install
npm install --save react-use-asset-loader
Usage
import * as React from "react";
import useLoadAssets from "react-use-asset-loader";
const Example = () => {
const loadAssets = useLoadAssets();
return (
<button
onClick={() =>
loadAssets({
assets: [
{
type: "link",
values: {
url: "https://sample.css",
id: "sample-css",
rel: "stylesheet",
type: "text/css",
},
},
{
type: "script",
values: {
url: "https://sample.js",
id: "sample-js",
},
},
],
})
}
>
Test
</button>
);
};
License
MIT © marcoSven
This hook is created using create-react-hook.