react-context-io
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i react-context-io

Weekly Downloads

2

Version

0.0.7

License

MIT

Unpacked Size

6.91 kB

Total Files

12

Last publish

Collaborators

  • yesmeck