-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move safety checks inside combineReducer to first invocation #717
Comments
Another possible alternative is to create errors and |
Would anybody like to work on this? |
Sure, I'll be able to take a look in the next couple of days. |
@gaearon I have been working on this, but I am new to the dark arts of HMR and I have a question. In the following module taken from the counter example, I think delaying the sanity check until the dispatch of the @@init action will still blow up the module definition because the init action is getting dispatched either inside
I've got a couple of potential ideas to get around this if it is indeed a problem, just wanted to check that I am not misunderstanding how the HMR works. |
It will below up the first time you launch the app but I don't think it's a big deal. It's iteration that I'm concerned about (changing reducers or adding new ones). In case of iteration only the reducer file and replaceReducer() call will be evaluated. |
Ah, thanks! That makes total sense. I should read my error messages. The error thrown on iteration is caused by the |
Yeah—that's a different thing, reduxjs/redux-devtools#106 |
So to achieve our goal that devtools issue will need to be addressed too I guess. Having this error thrown from the dispatch in |
Yes, but these are two separate issues. When I tested, fixing them both locally fixed the problem. |
Yes, agreed. |
move combine reducers sanity check #717
Done in #717. |
Released in 3.0.1. |
There is still a problem with the scenario I described above. If the reducer throws, then the reducer sanity check itself will throw. In other words, Object.keys(finalReducers).forEach(key => {
var reducer = finalReducers[key];
if (!sanityError && typeof reducer(undefined, { type: ActionTypes.INIT }) === 'undefined') { See that
@ellbee Can you look into this? |
Ah yes, I see. Quick fix attempt here #807 |
Fixed via #807. |
Final fix in 3.0.2, confirmed as working. |
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 thecombineReducers()
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
The text was updated successfully, but these errors were encountered: