Trying out React + Redux, and probably am doing something obviously stupid, because a component that fires an action to fetch data over the network does not get updated (re-rend
I am surprized to see that the state contains reducers from the rootReducer
This is how it works. Take a closer look at combineReducers()
.
const rootReducer = combineReducers({
navigationReducer,
resourcesReducer
});
Recognise that it's not a list of parameters; it's a single object parameter. Perhaps it is clearer in verbose syntax:
var rootReducer = combineReducers({
navigationReducer: navigationReducer,
resourcesReducer: resourcesReducer
});
The resourcesReducer
key points to the state returned by the resourcesReducer()
function. That is, the state
variable within the resourcesReducer()
is just one part of the entire state.
The functions passed to connect()
take the entire state as an argument. What yours should actually look like is this:
export default connect(state => ({
resources: state.resourcesReducer.resources
}))(Showcase);