New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-external-script-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-external-script-loader

React component for loading external scripts

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
339
decreased by-17.72%
Maintainers
1
Weekly downloads
 
Created
Source

react-external-script-loader

Library for loading external scripts

Install

npm install react-external-script-loader
yarn add react-external-script-loader

Usage

import Loader from 'react-external-script-loader';

...

<Loader url="https://vk.com/js/api/openapi.js?160" global="VK" />

Component

Options

PropertyTypeDescription
url(required)stringUrl of external script
global(required)stringname of object if it loads successfully
optionsobjectScript options - possible keys: {type, charset, async, defer}. You can ckeck it here
onLoadfunctionCalled when script loaded (global: object): void
onErrorfunctionCalled when script loading was failed void

Basic example

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

TODO

  • Add tests
  • Write clearer description
  • Write more examples

Keywords

FAQs

Package last updated on 27 Feb 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc