react-polyfill-context

1.0.12 • Public • Published

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

/react-polyfill-context/

    Package Sidebar

    Install

    npm i react-polyfill-context

    Weekly Downloads

    8

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    3.59 kB

    Total Files

    4

    Last publish

    Collaborators

    • kingback