This package has been deprecated

Author message:

This package has been moved to react-script-hook

@wapps/react-script-loader

0.0.7 • Public • Published

react-script-loader

Build Status

React script loader

Installation

npm install --save @wapps/react-script-loader

How to use

import React, { Component } from 'react';
import withScriptLoader from '@wapps/react-script-loader';

class GoogleMaps extends Component {
  ...

  componentDidMount() {
    const { hasScriptsLoaded, hasScriptsLoadedSuccessfully } = this.props;
    if (hasScriptsLoaded && hasScriptsLoadedSuccessfully) {
      this.setState({
        googleMaps: window.google.maps,
      });
    }
  }

  componentDidUpdate(prevProps) {
    const { hasScriptsLoaded, hasScriptsLoadedSuccessfully } = this.props;
    if (hasScriptsLoaded && !prevProps.hasScriptsLoaded) {
      if (hasScriptsLoadedSuccessfully) {
        this.setState({
          googleMaps: window.google.maps,
        });
      }
    }
  }

  ...
}

export default withScriptLoader({
  src: 'https://maps.googleapis.com/maps/api/js...'
})(GoogleMaps)

License

MIT

/@wapps/react-script-loader/

    Package Sidebar

    Install

    npm i @wapps/react-script-loader

    Weekly Downloads

    4

    Version

    0.0.7

    License

    MIT

    Unpacked Size

    7.69 kB

    Total Files

    5

    Last publish

    Collaborators

    • hupe1980