Skip to content

Instantly share code, notes, and snippets.

@akmur
Created March 15, 2019 10:29
Show Gist options
  • Save akmur/a6919743d85d564c2d0b81c989439aae to your computer and use it in GitHub Desktop.
Save akmur/a6919743d85d564c2d0b81c989439aae to your computer and use it in GitHub Desktop.
// 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