Redux thunk and asynchronous API calls

This commit is contained in:
Rodrigo Pedroso 2019-06-19 17:08:53 -04:00
commit 5ecf405fde
7 changed files with 64 additions and 2 deletions

View file

@ -1,7 +1,8 @@
import { ADD_ARTICLE } from '../constants/action-types'
const initialState = {
articles: []
articles: [],
remoteArticles: []
}
function rootReducer(state = initialState, action) {
@ -11,6 +12,12 @@ function rootReducer(state = initialState, action) {
})
}
else if (action.type === "DATA_LOADED") {
return Object.assign({}, state, {
remoteArticles: state.remoteArticles.concat(action.payload)
})
}
return state
}