-
Notifications
You must be signed in to change notification settings - Fork 642
Calling routerReducer() with no args crashes #349
Comments
Fixes reactjs#349 in parent Also fixed a typo in the function comment.
Babel is handling destructuring properly. nil/null/undefined handling is a normal problem with just about every weak typed language out there. Even when it's natively supported by the VM, it still means you're trying to access a property of undefined. I'm not sure what the spec says about that, but I imagine it handles it with an error as well. |
Thanks for the merge. I can understand the I tried reading the spec, but wow...not an easy doc to read, even just the sections on destructuring!
|
@timdorr Any idea when we can get a new release with this fix in it? Thanks! |
I'll try to get something out tonight. For now, you can install straight from github. |
Thanks! Much appreciated Tim! |
If you call
routerReducer()
with no arguments to get back the initial state, it crashes with the following error:reducer.js: Uncaught TypeError: Cannot read property 'type' of undefined
The generated code looks like this:
This can be fixed in the original code by adding a default parameter for the action parameter:
It made me wonder though what the correct behavior of Babel should be here. Should it provide safe destructuring or still leave that up to your code? I checked Traceur though and it behaves the same way, so perhaps that's not part of the spec, but it seems dangerous.
The text was updated successfully, but these errors were encountered: