Redux boilerplate code
This commit is contained in:
parent
b794708e2e
commit
69d47c85f0
8 changed files with 12058 additions and 7 deletions
17
src/js/reducers/index.js
Normal file
17
src/js/reducers/index.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { ADD_ARTICLE } from "../constants/action-types"
|
||||
|
||||
const initialState = {
|
||||
articles: []
|
||||
}
|
||||
|
||||
function rootReducer(state = initialState, action) {
|
||||
if (action.type === ADD_ARTICLE) {
|
||||
return Object.assign({}, state, {
|
||||
articles: state.articles.concat(action.payload)
|
||||
})
|
||||
}
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
export default rootReducer
|
Loading…
Add table
Add a link
Reference in a new issue