I had set InitialState in my redux createStore method ,and I corresponding InitialState as second arguments
I got a error in browser:
Un
as per the documentation of redux: https://redux.js.org/basics/reducers
you need to return state out side of switch function like this:
function posts(state=initialState,action) {
switch (action.type) {
case INVALIDATE_SUBREDDIT:
return state.merge({
didInvalidate: true
})
case REQUEST_POSTS:
return state.merge({
isFetching: true,
didInvalidate: false
})
case RECEIVE_POSTS:
return state.merge({
isFetching: false,
didInvalidate: false,
items: action.posts,
lastUpdated: action.receivedAt
})
default:
return state
}
//here you should put the return state
return state
}