Skip to content

Commit 336cbf8

Browse files
author
Brian Vaughn
authored
Fix react-is memo and lazy type checks (#17278)
1 parent 1257b1d commit 336cbf8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ReactShallowRenderer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class ReactShallowRenderer {
542542
);
543543
invariant(
544544
isForwardRef(element) ||
545-
(typeof element.type === 'function' || isMemo(element.type)),
545+
(typeof element.type === 'function' || isMemo(element)),
546546
'ReactShallowRenderer render(): Shallow rendering works only with custom ' +
547547
'components, but the provided element type was `%s`.',
548548
Array.isArray(element.type)
@@ -559,15 +559,15 @@ class ReactShallowRenderer {
559559
this._reset();
560560
}
561561

562-
const elementType = isMemo(element.type) ? element.type.type : element.type;
562+
const elementType = isMemo(element) ? element.type.type : element.type;
563563
const previousElement = this._element;
564564

565565
this._rendering = true;
566566
this._element = element;
567567
this._context = getMaskedContext(elementType.contextTypes, context);
568568

569569
// Inner memo component props aren't currently validated in createElement.
570-
if (isMemo(element.type) && elementType.propTypes) {
570+
if (isMemo(element) && elementType.propTypes) {
571571
currentlyValidatingElement = element;
572572
checkPropTypes(
573573
elementType.propTypes,
@@ -618,7 +618,7 @@ class ReactShallowRenderer {
618618
this._mountClassComponent(elementType, element, this._context);
619619
} else {
620620
let shouldRender = true;
621-
if (isMemo(element.type) && previousElement !== null) {
621+
if (isMemo(element) && previousElement !== null) {
622622
// This is a Memo component that is being re-rendered.
623623
const compare = element.type.compare || shallowEqual;
624624
if (compare(previousElement.props, element.props)) {
@@ -807,7 +807,7 @@ function getDisplayName(element) {
807807
} else if (typeof element.type === 'string') {
808808
return element.type;
809809
} else {
810-
const elementType = isMemo(element.type) ? element.type.type : element.type;
810+
const elementType = isMemo(element) ? element.type.type : element.type;
811811
return elementType.displayName || elementType.name || 'Unknown';
812812
}
813813
}

0 commit comments

Comments
 (0)