Skip to content

Instantly share code, notes, and snippets.

@yogieputra8
Created February 6, 2018 14:10
Show Gist options
  • Save yogieputra8/f763475ee1630b72e693fbac5e64e3d4 to your computer and use it in GitHub Desktop.
Save yogieputra8/f763475ee1630b72e693fbac5e64e3d4 to your computer and use it in GitHub Desktop.
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