Created
August 13, 2017 06:34
-
-
Save pycraft114/3e8ee0bbd5c90d496a3b4a82534c9901 to your computer and use it in GitHub Desktop.
why reducers should be pure
This file contains hidden or 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
//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