Naive implementation of rfcs#89.
$ npm i react-context-io
Or
$ yarn add react-context-io
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>
);