-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
isPlainObject()
util returns false
for objects without prototypes
#1074
Comments
Can you give examples of these selectors? Why are they written that way? What use cases are you working with, and how are things breaking? Are you sure this is really an issue on the React-Redux side, or are you actually seeing the use of the same function in the Redux core? The codebase only uses |
A
I'm afraid it does affect these cases, and it causes exceptions to be thrown in dev mode, which makes development...difficult. Are you opposed to the fix in PR #1075? If so, why? |
Noticed you added an additional question in an edit:
Yes, this is an issue in React-Redux. Given that Redux uses an identical stripped-down |
Thanks for the additional info. You're right - that is from React-Redux, as it's attempting to verify that the initial value returned from This implementation of I'm not opposed to the change in principle - looks like it's really adding just the one-line check, plus there was a formatting change? I'll let @timdorr make the call on that, since he wrote this function. However, I am kinda confused on the stack trace you showed, for two reasons:
What version of React-Redux are you using? Have you recently changed that? |
Hmm. If there was a formatting change it was unintentional, but I'm not seeing it. Could you point it out in a comment on the PR? The change is more than just a single-line change; I was trying to both preserve the original behavior of the function and cover this new use case with minimal perf impact.
Whoops, sorry. I inadvertently copied and pasted a stack trace from a modified version of the file. I had added a
The attempt to print a dev warning is itself causing this error by attempting to concatenate |
Eh, I guess it was the way I was viewing the diff. Thanks for the explanation on the error there. (Side question: is there any tweak we can make to that logic so it doesn't crash if there's no The change seems reasonable to me. However, we need to do more than just merge it straight to master. That's currently got our 6.0-beta code in it. We're going to need to set up a 5.x branch and merge this into that branch too for a 5.1.1 release, and we should make the same change to the Redux core to keep the behavior in sync. @timdorr , can you deal with the branching and merging aspects on this one? |
Yeah, I'll poke it with a stick tomorrow. |
@rgrove : the one thing I didn't get an answer to earlier - just for reference, what version of React-Redux are you on, and did you happen to upgrade recently? |
@markerikson Sorry. We encountered this bug while trying to upgrade from 5.0.7 to 5.1.0. |
Okay, yeah, that would be the first release that had this changed version of |
Cherry picking into 5.1.1. |
This is also out as 6.0 beta 3: https://github.com/reduxjs/react-redux/releases/tag/v6.0.0-beta.3 |
Object.create(null)
produces a plain object whose prototype isnull
. Lodash'sisPlainObject()
correctly treats this as a plain object, but theisPlainObject()
helper introduced in #936 does not. This broke our app, since we have a number of selectors which return prototypeless objects.PR to follow.
The text was updated successfully, but these errors were encountered: