Skip to content

Instantly share code, notes, and snippets.

@wclittle

wclittle/chat.js Secret

Created December 28, 2015 22:24
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 wclittle/cfcfd1c49dc319cf9879 to your computer and use it in GitHub Desktop.
Save wclittle/cfcfd1c49dc319cf9879 to your computer and use it in GitHub Desktop.
import { SET_MESSAGES, ADD_MESSAGE } from '../actions/chat';
export default function chat(state = {}, action) {
const { type, messages } = action;
switch (type) {
case ADD_MESSAGE:
return [
...state,
action.message
]
case SET_MESSAGES:
return messages
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment