Redux thunk and asynchronous API calls
This commit is contained in:
parent
b556441459
commit
5ecf405fde
7 changed files with 64 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue