Created
February 6, 2018 14:10
-
-
Save yogieputra8/f763475ee1630b72e693fbac5e64e3d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware' | |
import { | |
FETCH_DATA, | |
FETCH_BANNERS | |
} from '../actions/index' | |
export const data = (state = { | |
items: '', | |
}, action) => { | |
switch (action.type){ | |
case `${FETCH_DATA}`: | |
return { | |
...state, | |
items: 'This is data from redux' | |
} | |
default: | |
return state | |
} | |
} | |
export const banners = (state = { | |
isFetching: false, | |
items: [] | |
}, action) => { | |
switch (action.type){ | |
case `${FETCH_BANNERS}_PENDING`: | |
return { | |
...state, | |
isFetching: true | |
} | |
case `${FETCH_BANNERS}_FULFILLED`: | |
return { | |
...state, | |
isFetching: false, | |
items: action.payload | |
} | |
case `${FETCH_BANNERS}_REJECTED`: | |
return { | |
...state | |
} | |
default: | |
return state | |
} | |
} | |
const rootReducer = combineReducers({ | |
data, | |
banners | |
}) | |
export default rootReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment