Created
August 13, 2017 06:36
-
-
Save pycraft114/664185907feaf52937716d78b0904b0c 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 | |
}; | |
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