Skip to content

Commit

Permalink
fix #11759. false positive warning in IE11 when using React.Fragment (#…
Browse files Browse the repository at this point in the history
…11823)

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

* simplify createElementWithValidation type check

* fix mistake

* Add an explanation

* We shouldn't use `number` for anything else

* Clarify further
  • Loading branch information
XaveScor authored and gaearon committed Dec 11, 2017
1 parent abdbb16 commit a5025b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react/src/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ export function createElementWithValidation(type, props, children) {
const validType =
typeof type === 'string' ||
typeof type === 'function' ||
typeof type === 'symbol' ||
typeof type === 'number';
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE;

// 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 +337,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

0 comments on commit a5025b1

Please sign in to comment.