-
-
Save vhnam/b56f6661bc95057961a233f5b38dd2b4 to your computer and use it in GitHub Desktop.
Redux __ Step 1
This file contains 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
import { ADD_ARTICLE } from '../constants/action-types' | |
const initialState = { | |
articles: [] | |
} | |
const rootReducer = (state = initialState, action) => { | |
switch (action.type) { | |
case ADD_ARTICLE: | |
return { ...state, articles: [...state.articles, action.payload] } | |
default: | |
return state | |
} | |
} | |
export default rootReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment