1.0.12 • Published 3 years ago

react-polyfill-context v1.0.12

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

react-polyfill-context

Polyfill for React new context api

Support

>= react@0.14.9

Usage

import React from 'react';
import { render } from 'react-dom';
import { createContext } from 'react-polyfill-context';
const Context = createContext();

function App() {
  return (
    <div>
      <Context.Consumer>{(value) => (
        <p>{value}</p>
      )}</Context.Consumer>
    </div>
  );
}

render((
  <Context.Provider value={0}>
    <App />
  </Context.Provider>
), document)

For more usage, see https://reactjs.org/docs/context.html#reactcreatecontext

Others

You can use it with react-polyfill-ref and react-polyfill-hooks