Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import * as types from './types'
  2.  
  3. export const initialState = {
  4. data: null,
  5. isLoading: false,
  6. errorMessage: '',
  7. }
  8.  
  9. export const reducer = (state = initialState, action = {}) => {
  10. switch (action.type) {
  11. case types.STOCKS_REQUEST: {
  12. return {
  13. ...state,
  14. isLoading: true,
  15. }
  16. }
  17. case types.STOCKS_SUCCESS: {
  18. return {
  19. ...state,
  20. isLoading: false,
  21. errorMessage: '',
  22. data: action.payload,
  23. }
  24. }
  25. case types.STOCKS_ERROR: {
  26. return {
  27. ...state,
  28. isLoading: false,
  29. errorMessage: action.payload,
  30. data: null,
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement