crubier / react-loadable-context

Asynchronously load object into the context

Home Page:https://crubier.github.io/react-loadable-context/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

npm install --save react-loadable-context

Just like the new context API, 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 and the new context API.

About

Asynchronously load object into the context

https://crubier.github.io/react-loadable-context/

License:MIT License


Languages

Language:JavaScript 96.5%Language:HTML 3.5%