import { handleActions } from 'redux-actions';
const getInitialState = () => {
return ['red'];
};
const reducer = handleActions({
test: (state, action) => {
return action.payload.a ? undefined : ['yellow'];
},
test2: (state) => {
return ['1'];
}
}, getInitialState());
const reducer2 = handleActions({
test: (state, action) => {
return action.payload.a ? undefined : ['yellow'];
}
}, getInitialState());
console.log(reducer(['green'], {
type: 'test',
payload: {
a: 1
}
}));
// ['red']
console.log(reducer2(['green'], {
type: 'test',
payload: {
a: 1
}
}));
// undefined