Skip to content

Instantly share code, notes, and snippets.

@csandeep
Created March 7, 2016 12:32
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 csandeep/a50f74e88c33b8437fc8 to your computer and use it in GitHub Desktop.
Save csandeep/a50f74e88c33b8437fc8 to your computer and use it in GitHub Desktop.
The Reducer
import {Constants} from '../api/Constants';
var update = require('react-addons-update');
export default function postReducer(state, action) {
switch(action.type) {
case Constants.SET_POST_TEXT:
if( state.data.text){
return update(state, {
data: { $merge: {text: action.text }}
});
}else{
return update(state, {
data: { $merge: {text: action.text }}
});
}
break;
case Constants.SET_POST_NAME:
return update(state, {
data: { name: { $set: action.text }}
});
return newO;
break;
case Constants.SET_POST_DESCRIPTION:
return update(state, {
data: { description: { $set: action.text }}
});
break;
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment