context-hooks
React Hooks for accessing state and dispatch from a store
Install
# Yarn yarn add context-hooks # NPM npm install --save context-hooks
Quick Start
// bootstrap your app import StoreContext createStore from 'context-hooks' ReactDOM
// individual components import useReducers useConntect from 'context-hooks' const App = const state = const counter = return <Fragment> Count: count<br /> <button =>increase count</button> <button =>decrease count</button> </Fragment>
Usage
NOTE: React hooks require react
and react-dom
version 16.8.0
or higher.
Example
// reducers counter: initialState: count: 0 count: statecount + 1 count: statecount - 1
// bootstrap your app import StoreContext createStore from 'context-hooks'import reducers from './reducers' const store = ReactDOM
// individual components import useReducers useConntect from 'context-hooks' const App = const state = const counter = return <Fragment> Count: count<br /> <button =>increase count</button> <button =>decrease count</button> </Fragment>