This may not be an issue actually. Is the name of the imported reference equals to the property name of "state" when I call mapStateToProps? e.g. I need to use "state.someReducers". I am still new to redux, perhaps I missed something in documentation.
import someReducers from './someReducers';
const rootReducer = combineReducers({
someReducers
});
Why don't we do it more explicit?
import someReducers from './someReducers';
const rootReducer = combineReducers({
items: someReducers
});
Yes, the shape of the object passed into combineReducers matches the store state that those reducers will operate on. If we do { itemsReducers }, that desugars to { itemsReducers: itemsReducers }, which is probably not what you want. I normally do something like this:
import items from './someReducers';
const rootReducer = combineReducers({
items
});
Your import name can be whatever you want it to be, so you can match it to your state shape.
There's a balance between being explicit in examples and showing what we believe to be best practices. We don't really want to encourage people to name reducer files someReducers; the convention we encourage is to match reducer name to the state field name. But then writing { something: something } is redundant in ES6 so we don't do that either.
Most helpful comment
There's a balance between being explicit in examples and showing what we believe to be best practices. We don't really want to encourage people to name reducer files
someReducers; the convention we encourage is to match reducer name to the state field name. But then writing{ something: something }is redundant in ES6 so we don't do that either.