Skip to content
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

fix #11759. false positive warning in IE11 when using React.Fragment #11823

Merged
merged 6 commits into from
Dec 11, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/react/src/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ export function createElementWithValidation(type, props, children) {
const validType =
typeof type === 'string' ||
typeof type === 'function' ||
typeof type === 'symbol' ||
typeof type === 'number';
typeof type === 'number' ||
type === 'REACT_FRAGMENT_TYPE';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don’t understand why this change is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because type of polyfilled Symbol is object. This check cannot catch this situation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this compare to REACT_FRAGMENT_TYPE itself then? Without quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks. I am so stupid.

// We warn in this case but don't throw. We expect the element creation to
// succeed and there will likely be errors in render.
if (!validType) {
Expand Down Expand Up @@ -336,7 +336,7 @@ export function createElementWithValidation(type, props, children) {
}
}

if (typeof type === 'symbol' && type === REACT_FRAGMENT_TYPE) {
if (type === REACT_FRAGMENT_TYPE) {
validateFragmentProps(element);
} else {
validatePropTypes(element);
Expand Down