194
rated 0 times
[
199]
[
5]
/ answers: 1 / hits: 29510
/ 8 Years ago, wed, february 24, 2016, 12:00:00
Sometimes reducers get kind of messy:
const initialState = {
notificationBar: {
open: false,
},
};
export default function (state = initialState, action) {
switch (action.type) {
case actions.LAYOUT_NOTIFICATIONBAR_OPEN:
return Object.assign({}, state, {
// TODO: Find a cleaner way to do this!
notificationBar: Object.assign({}, state.notificationBar, {
open: true,
}),
});
default:
return state;
}
}
Is there a more terse way to do this?
More From » reactjs