Skip to content

Instantly share code, notes, and snippets.

@pmqa pmqa/Reducer.js
Created Jan 11, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.