JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 541
  • Score
    100M100P100Q93457F
  • License MIT

Require JavaScript libraries from the web

Package Exports

  • react-weblibrary
  • react-weblibrary/dist/cjs/index.js
  • react-weblibrary/dist/esm/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-weblibrary) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-weblibrary

Another react hook for loading scripts from the web

import { useWebLibrary } from 'react-weblibrary'

function MyComponent() {
   // Expect the script from https://example.com/someLibrary to define `window.$`.
   // If the global exists (e.g. because the script is already requested in <head>), the script will not be requested again.
   const [someLibrary, status] = useWebLibrary('$', 'https://example.com/someLibrary')

   if (!someLibrary) {
      return status === 'try' ? 'Still loading...' : 'Something went wrong.'
   }

   someLibrary.someFunction()
}