Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
react-external-script-loader
Advanced tools
Weekly downloads
Readme
Library for loading external scripts
npm install react-external-script-loader
yarn add react-external-script-loader
import Loader from 'react-external-script-loader';
...
<Loader url="https://vk.com/js/api/openapi.js?160" global="VK" />
Property | Type | Description |
---|---|---|
url(required) | string | Url of external script |
global(required) | string | name of object if it loads successfully |
options | object | Script options - possible keys: {type, charset, async, defer}. You can ckeck it here |
onLoad | function | Called when script loaded (global: object): void |
onError | function | Called when script loading was failed void |
import Loader from 'react-external-script-loader';
class App extends React.Component {
state = {
load: false,
};
render() {
const { load } = this.state;
return (
<div className="App">
<h1>React External Script Loader Example</h1>
<button onClick={() => this.setState({ load: true })}>
Load external script
</button>
{load && (
<>
<div id="vk_playlist_-2000646569_646569" />
<Loader
url="https://vk.com/js/api/openapi.js?160"
global="VK"
onLoad={VK =>
VK.Widgets.Playlist(
'vk_playlist_-2000646569_646569',
-2000646569,
646569,
'ae82627d6c8bb4500d',
)
}
/>
</>
)}
</div>
);
}
}
const rootElement = document.getElementById('root');
ReactDOM.render(<App />, rootElement);
You can clone this repository and check example
git clone https://github.com/mmarkelov/react-external-script-loader.git
cd ./react-external-script-loader/example
yarn && yarn run dev
FAQs
React component for loading external scripts
The npm package react-external-script-loader receives a total of 153 weekly downloads. As such, react-external-script-loader popularity was classified as not popular.
We found that react-external-script-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.