Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crubier/react-loadable-context
Asynchronously load object into the context
https://github.com/crubier/react-loadable-context
Last synced: about 1 month ago
JSON representation
Asynchronously load object into the context
- Host: GitHub
- URL: https://github.com/crubier/react-loadable-context
- Owner: crubier
- License: mit
- Created: 2018-05-20T13:20:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T01:44:57.000Z (over 6 years ago)
- Last Synced: 2024-11-08T00:37:38.068Z (3 months ago)
- Language: JavaScript
- Homepage: https://crubier.github.io/react-loadable-context/
- Size: 753 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-state-management - react-loadable-context - Small wrapper around the React Context API to asynchronously load and inject objects into the context. (List)
- awesome-react-context - **react-loadable-context** - Small wrapper around the React Context API to asynchronously load and inject objects into the context. (Libraries)
README
# react-loadable-context
Website at https://crubier.github.io/react-loadable-context/
A component to asynchronously load any object into the react context, for example when using [Code Splitting](https://webpack.js.org/guides/code-splitting/).
```
npm install --save react-loadable-context
```Just like [the new context API](https://reactjs.org/docs/context.html), this function returns:
* A `Provider`, which injects the loaded object into the context as soon as the promise is resolved
* Various `Consumer` components, which gracefully handle loading and error states.This is particularly usefull when creating libraries which interface react with third party heavy libraries, such as Cesium, vis.js, openlayers and others. The main "wrapper" component for the library uses the `Provider`. The various "elements" of the library use the `Consumer`.
Losely inspired by [react-loadable](https://github.com/jamiebuilds/react-loadable) and [the new context API](https://reactjs.org/docs/context.html).