Closed
Description
Currently we make a bunch of invariant tests inside combineReducers()
to make sure it's not being misused in common ways. These tests currently occur at the combineReducers()
call time.
This makes Redux DevTools unable to catch the errors inside reducers, as they often trigger those invariants to blow up during module definition, and abort hot reloading. Instead, I propose to move the tests to the first real invocation of the combined reducer. In most cases that would be createStore
call because it causes an implicit initial dispatch. This way Redux DevTools can catch and display such errors.
Shall we do that? The code would change to be like
var reducerSanityVerified;
var stateShapeVerified;
// don't do it here
return function combination(state = defaultState, action) {
if (!reducerSanityVerified) {
Object.keys(finalReducers).forEach(key => {
// do that stuff