Created
September 6, 2016 16:03
-
-
Save timbuckley/a74161fb641e8e6da0d35fe5b12c78de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function itemsReducer(state, action) { | |
switch(action.type) { | |
case 'UPDATE_ITEM': | |
return state.items.map(i => itemReducer(i, action)) | |
default: | |
return state | |
} | |
} | |
function itemReducer(state, action) { | |
switch(action.type) { | |
case 'UPDATE_ITEM': | |
return { | |
...state, | |
[action.payload.fieldToChange]: action.payload.newValue | |
} | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment