Skip to content

Instantly share code, notes, and snippets.

@pycraft114
Created August 13, 2017 06:34
Show Gist options
  • Save pycraft114/3e8ee0bbd5c90d496a3b4a82534c9901 to your computer and use it in GitHub Desktop.
Save pycraft114/3e8ee0bbd5c90d496a3b4a82534c9901 to your computer and use it in GitHub Desktop.
why reducers should be pure
//initial state
const data = {
id : null,
password : null
};
export default function(state = data, action){
switch(action.type){
case ID_MODIFIED:
state.id = action.payload;
return state;
case PW_MODIFIED:
state.password = action.payload;
return state;
default ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment