reducerFactory.js
416 Bytes
export default function createReducer(initialState, types) {
return function reducer(state = initialState, action) {
const typesProperty={};
types.map((type,i)=>{
typesProperty[type]=type;
});
if(typesProperty.hasOwnProperty(action.type)){
const tempState= Object.assign({}, state,{...action});
delete tempState.type;
return tempState;
}else{
return state;
}
}
}