Skip to content

yesmeck/react-context-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Share state with ease.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published