-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Improve component type check in getComponentKey. #9464
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
Conversation
The sequence ``` component && typeof component === 'object' ``` checks whether component is any JavaScript object except document.all. Since document.all cannot occur here, this can be replaced with the usual ``` typeof component === 'object' && component !== null ``` sequence, which yields true for all JavaScript objects and is well optimized by all JavaScript engines.
Looks good to me, thanks. Let’s wait for CI. |
That being said: it obviously filters out callable objects still. |
Looks like you need to run if (
typeof component === "object" &&
component !== null &&
component.key != null
) { |
Done. Although it didn't split it into three lines. |
Likely because we haven’t updated to the last version yet (we will soon). |
Anything else missing? |
Oh, my bad. My local prettier did but I may have been using a diff version. :) No, looks good. Thanks for following up! |
Thanks! |
Thanks @bmeurer! |
The sequence
checks whether component is any JavaScript object except document.all.
Since document.all cannot occur here, this can be replaced with the
usual
sequence, which yields true for all JavaScript objects and is well
optimized by all JavaScript engines.