@@ -45,7 +45,9 @@ export function typeOf(object: any) {
4545 case REACT_ASYNC_MODE_TYPE :
4646 case REACT_FRAGMENT_TYPE :
4747 case REACT_STRICT_MODE_TYPE :
48- return maybeType ;
48+ if ( getTypeOf ( object ) === REACT_ELEMENT_TYPE ) {
49+ return maybeType ;
50+ }
4951 }
5052
5153 maybeType = getTypeTypeOf ( object ) ;
@@ -72,7 +74,10 @@ export const Portal = REACT_PORTAL_TYPE;
7274export const StrictMode = REACT_STRICT_MODE_TYPE ;
7375
7476export function isAsyncMode ( object : any ) {
75- return getType ( object ) === REACT_ASYNC_MODE_TYPE ;
77+ return (
78+ getType ( object ) === REACT_ASYNC_MODE_TYPE &&
79+ getTypeOf ( object ) === REACT_ELEMENT_TYPE
80+ ) ;
7681}
7782export function isContextConsumer ( object : any ) {
7883 return getTypeTypeOf ( object ) === REACT_CONTEXT_TYPE ;
@@ -84,11 +89,17 @@ export function isElement(object: any) {
8489 return getTypeOf ( object ) === REACT_ELEMENT_TYPE ;
8590}
8691export function isFragment ( object : any ) {
87- return getType ( object ) === REACT_FRAGMENT_TYPE ;
92+ return (
93+ getType ( object ) === REACT_FRAGMENT_TYPE &&
94+ getTypeOf ( object ) === REACT_ELEMENT_TYPE
95+ ) ;
8896}
8997export function isPortal ( object : any ) {
9098 return getTypeOf ( object ) === REACT_PORTAL_TYPE ;
9199}
92100export function isStrictMode ( object : any ) {
93- return getType ( object ) === REACT_STRICT_MODE_TYPE ;
101+ return (
102+ getType ( object ) === REACT_STRICT_MODE_TYPE &&
103+ getTypeOf ( object ) === REACT_ELEMENT_TYPE
104+ ) ;
94105}
0 commit comments