Skip to content

Instantly share code, notes, and snippets.

@vhnam
Created September 7, 2018 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vhnam/b56f6661bc95057961a233f5b38dd2b4 to your computer and use it in GitHub Desktop.
Save vhnam/b56f6661bc95057961a233f5b38dd2b4 to your computer and use it in GitHub Desktop.
Redux __ Step 1
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