combine-reducers-hook
v1.0.3
Published
combineReducers for using 'useReducer' of react hook
Downloads
4
Readme
CombineReducers for using 'useReducer' of react hook
Install
Install with npm:
$ npm install --save combine-reducers-hook
Usage
store/reducers.js
export default{
testName(state='ttt',action){
const {type,payload} = action;
switch(type){
case SET_NAME:
return payload;
default:
}
return state
}
}
store/index.js
import React,{useReducer,createContext} from 'react';
import combineReducers from 'combine-reducers-hook';
import reducers from './reducers';
let [state,dispatch] = useReducer(combineReducers(reducers),initState);
See the examples folder for usage examples.