reducer example redux
Example 1: redux reducer
const Reducer = (state=[],action) =>{
switch(action.type){
case'add':
return [...state,action.payload]
default:
return state ;
}
}
Example 2: react/redux reducers sintaxe
const reduxSinaxe = (state = [], action) => {
switch (action.type) {
case "@smthg/ACTION":
const { anyConst } = action;
return [...state, anyConst];
default:
return state;
}
};
export default reduxSinaxe;