Created
January 11, 2018 19:44
-
-
Save pmqa/3064d4766c293b3b203893faa450dfa5 to your computer and use it in GitHub Desktop.
Reducer
This file contains 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
import dotprop from 'dot-prop-immutable'; | |
import { | |
UPDATE_POST_TITLE, | |
LOAD_APP | |
} from './../constants/actionTypes'; | |
export default (state = {}, action) => { | |
switch (action.type) { | |
case LOAD_APP: | |
return action.payload | |
case UPDATE_POST_TITLE: | |
const nextState = dotprop.set(state, `posts.${action.payload.id}.title`, 'The title has been updated'); | |
return nextState; | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment