https://github.com/ph-fritsche/react-weblibrary
Require javascript libraries from the web
https://github.com/ph-fritsche/react-weblibrary
Last synced: 2 months ago
JSON representation
Require javascript libraries from the web
- Host: GitHub
- URL: https://github.com/ph-fritsche/react-weblibrary
- Owner: ph-fritsche
- License: mit
- Created: 2020-12-11T12:55:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-29T16:35:52.000Z (over 2 years ago)
- Last Synced: 2025-03-18T13:27:06.050Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 549 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-weblibrary
Another react hook for loading scripts from the web
```js
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 ), 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()
}
```