Skip to content

Instantly share code, notes, and snippets.

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