0.0.7 • Published 5 years ago

react-context-io v0.0.7

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

react-context-io

Naive implementation of rfcs#89.

Installation

$ npm i react-context-io

Or

$ yarn add react-context-io

Usage

import React, { useContext } from 'react';
import { createContextIO } from 'react-context-io';

const CountStore = createContextIO(0);

const Result = () => {
  const count = useContext(CountStore);
  return <div>{count}</div>;
};

const AddButton = () => (
  <button onClick={() => CountStore.write(count => count + 1)}>+</button>
);

const Counter = () => (
  <CountStore.Provider>
    <Result />
    <AddButton />
  </CountStore.Provider>
);

Live demo

License

MIT

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago