-
-
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
Refactor combineReduer's Unexpected State Shape Warning #1118
Refactor combineReduer's Unexpected State Shape Warning #1118
Conversation
b88deec
to
5bce135
Compare
This looks good to me. 👍 for using |
Someone else should review this too, though, since I'm not as familiar with this module. |
@@ -15,8 +15,8 @@ function getUndefinedStateErrorMessage(key, action) { | |||
) | |||
} | |||
|
|||
function getUnexpectedStateKeyWarningMessage(inputState, outputState, action) { | |||
var reducerKeys = Object.keys(outputState) | |||
function getUnexpectedStateShapeWarningMessage(inputState, reducer, action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument should probably be called reducers
, not reducer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
I think @ellbee should remember this better than me. |
I have just been playing with this, and I am pretty sure that this behaves the same as what is currently there. |
Leaving this for you to review then 👍 |
The shape of the previous state is irrelevant, what we’re actually testing is that state has the same shape as our reducer object `finalReducers`. Also fixes the algorithm to be O(n) by using `#hasOwnProperty` vs doing an array search.
5bce135
to
e5aabde
Compare
So, the changes in this PR are passing the finalReducer instead of outputState, the switch to |
…hape Refactor combineReduer's Unexpected State Shape Warning
Out in 3.0.6, thanks! |
The shape of the previous state is irrelevant, what we’re actually
testing is that state has the same shape as our reducer object
finalReducers
.Also fixes the algorithm to be O(n) by using
#hasOwnProperty
vs doingan array search O(n2).