This repository has been archived on 2024-11-29. You can view files and clone it, but cannot push or open issues or pull requests.

24 lines
533 B
JavaScript

import { ADD_ARTICLE, DATA_LOADED } from "../constants/action-types";
const initialState = {
articles: [],
remoteArticles: [],
};
function rootReducer(state = initialState, action) {
if (action.type === ADD_ARTICLE) {
return Object.assign({}, state, {
articles: state.articles.concat(action.payload),
});
}
if (action.type === DATA_LOADED) {
return Object.assign({}, state, {
remoteArticles: state.remoteArticles.concat(action.payload),
});
}
return state;
}
export default rootReducer;