npm.io
1.0.12 • Published 5 years ago

react-polyfill-context

Licence
MIT
Version
1.0.12
Deps
2
Size
4 kB
Vulns
0
Weekly
0
Stars
12

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

Keywords