Created
March 15, 2019 10:29
-
-
Save akmur/a6919743d85d564c2d0b81c989439aae to your computer and use it in GitHub Desktop.
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
// our initial state | |
const initialState = { | |
data: {}, | |
isLoaded: false | |
} | |
const userReducer = (state = initialState, action) => { | |
if (action.type === 'USER_LOADED') { | |
return { | |
...state, // this copies the old state | |
data: action.payload, // this overrides the "data" property | |
isLoaded: true // this overrides the "isLoaded" property | |
} | |
} | |
return state | |
} | |
export default userReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment