1.0.4 • Published 2 years ago

react-weblibrary v1.0.4

Weekly downloads
37
License
MIT
Repository
github
Last release
2 years ago

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()
}
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.0

3 years ago