Created
August 28, 2016 00:26
-
-
Save ericelliott/54fb771a2dedc60ff58a3e104ccc340e to your computer and use it in GitHub Desktop.
Reducer, sans boilerplate
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
const chatReducer = (state = defaultState, action = {}) => { | |
const { type, payload } = action; | |
switch (type) { | |
case ADD_CHAT: | |
return Object.assign({}, state, { | |
chatLog: state.chatLog.concat(payload) | |
}); | |
// Catch all simple changes | |
case CHANGE_STATUS: | |
case CHANGE_USERNAME: | |
return Object.assign({}, state, payload); | |
default: return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment