Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as types from './types'
- export const initialState = {
- data: null,
- isLoading: false,
- errorMessage: '',
- }
- export const reducer = (state = initialState, action = {}) => {
- switch (action.type) {
- case types.STOCKS_REQUEST: {
- return {
- ...state,
- isLoading: true,
- }
- }
- case types.STOCKS_SUCCESS: {
- return {
- ...state,
- isLoading: false,
- errorMessage: '',
- data: action.payload,
- }
- }
- case types.STOCKS_ERROR: {
- return {
- ...state,
- isLoading: false,
- errorMessage: action.payload,
- data: null,
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement