Skip to content

Instantly share code, notes, and snippets.

@pmqa
Created January 11, 2018 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmqa/3064d4766c293b3b203893faa450dfa5 to your computer and use it in GitHub Desktop.
Save pmqa/3064d4766c293b3b203893faa450dfa5 to your computer and use it in GitHub Desktop.
Reducer
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