Reducer.js 358 B

123456789101112131415161718192021222324252627
  1. import * as actions from "../constants/index";
  2. const initialState = {
  3. gotNews: [],
  4. // getNews: [],
  5. searchNews: []
  6. };
  7. export default (
  8. state = initialState,
  9. {
  10. gotNews,
  11. type
  12. }
  13. ) => {
  14. switch (type) {
  15. case actions.GET_NEWS:
  16. return{
  17. ...state,
  18. gotNews
  19. };
  20. default: {
  21. return { ...state};
  22. }
  23. }
  24. };