@@ -28,28 +28,39 @@ import {
28
28
} from 'shared/ReactSymbols' ;
29
29
30
30
export default function isValidElementType ( type : mixed ) {
31
- return (
32
- typeof type === 'string' ||
33
- typeof type === 'function' ||
34
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
31
+ if ( typeof type === 'string' || typeof type === 'function' ) {
32
+ return true ;
33
+ }
34
+
35
+ // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
36
+ if (
35
37
type === REACT_FRAGMENT_TYPE ||
36
38
type === REACT_PROFILER_TYPE ||
37
39
type === REACT_DEBUG_TRACING_MODE_TYPE ||
38
40
type === REACT_STRICT_MODE_TYPE ||
39
41
type === REACT_SUSPENSE_TYPE ||
40
42
type === REACT_SUSPENSE_LIST_TYPE ||
41
- type === REACT_LEGACY_HIDDEN_TYPE ||
42
- ( typeof type === 'object' &&
43
- type !== null &&
44
- ( type . $$typeof === REACT_LAZY_TYPE ||
45
- type . $$typeof === REACT_MEMO_TYPE ||
46
- type . $$typeof === REACT_PROVIDER_TYPE ||
47
- type . $$typeof === REACT_CONTEXT_TYPE ||
48
- type . $$typeof === REACT_FORWARD_REF_TYPE ||
49
- type . $$typeof === REACT_FUNDAMENTAL_TYPE ||
50
- type . $$typeof === REACT_RESPONDER_TYPE ||
51
- type . $$typeof === REACT_SCOPE_TYPE ||
52
- type . $$typeof === REACT_BLOCK_TYPE ||
53
- type [ ( 0 : any ) ] === REACT_SERVER_BLOCK_TYPE ) )
54
- ) ;
43
+ type === REACT_LEGACY_HIDDEN_TYPE
44
+ ) {
45
+ return true ;
46
+ }
47
+
48
+ if ( typeof type === 'object' && type !== null ) {
49
+ if (
50
+ type . $$typeof === REACT_LAZY_TYPE ||
51
+ type . $$typeof === REACT_MEMO_TYPE ||
52
+ type . $$typeof === REACT_PROVIDER_TYPE ||
53
+ type . $$typeof === REACT_CONTEXT_TYPE ||
54
+ type . $$typeof === REACT_FORWARD_REF_TYPE ||
55
+ type . $$typeof === REACT_FUNDAMENTAL_TYPE ||
56
+ type . $$typeof === REACT_RESPONDER_TYPE ||
57
+ type . $$typeof === REACT_SCOPE_TYPE ||
58
+ type . $$typeof === REACT_BLOCK_TYPE ||
59
+ type [ ( 0 : any ) ] === REACT_SERVER_BLOCK_TYPE
60
+ ) {
61
+ return true ;
62
+ }
63
+ }
64
+
65
+ return false ;
55
66
}
0 commit comments