Skip to content

Instantly share code, notes, and snippets.

@jurgob
Created March 17, 2016 20:11
Show Gist options
  • Save jurgob/0b820f681e6cabee4543 to your computer and use it in GitHub Desktop.
Save jurgob/0b820f681e6cabee4543 to your computer and use it in GitHub Desktop.
redux-utils - reducer without utils
const layoutDefState = {
isEditorExpanded: false,
direction:"horizontal"
}
function layout(state=layoutDefState, action) {
switch (action.type){
case ACT.LAYOUT_TOOGLE_EDITOR_EXPANDED:
return {
…state,
isEditorExpanded: !state.isEditorExpanded
}
case ACT.LAYOUT_TOOGLE_DIRECTION:
console.log(‘layout’, action.type);
return {
…state,
direction: (
state.direction === ‘vertical’
? ‘horizontal’
: ‘vertical’
)
}
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment