mirror of
https://github.com/facebook/react.git
synced 2026-02-25 22:04:59 +00:00
* Expose LegacyHidden type I will use this internally at Facebook to migrate away from <div hidden />. The end goal is to migrate to the Offscreen type, but that has different semantics. This is an incremental step. * Disable <div hidden /> API in new fork Migrates to the unstable_LegacyHidden type instead. The old fork does not support the new component type, so I updated the tests to use an indirection that picks the correct API. I will remove this once the LegacyHidden (and/or Offscreen) type has landed in both implementations. * Add gated warning for `<div hidden />` API Only exists so we can detect callers in www and migrate them to the new API. Should not visible to anyone outside React Core team.
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import {
|
|
REACT_CONTEXT_TYPE,
|
|
REACT_FORWARD_REF_TYPE,
|
|
REACT_FRAGMENT_TYPE,
|
|
REACT_PROFILER_TYPE,
|
|
REACT_PROVIDER_TYPE,
|
|
REACT_DEBUG_TRACING_MODE_TYPE,
|
|
REACT_STRICT_MODE_TYPE,
|
|
REACT_SUSPENSE_TYPE,
|
|
REACT_SUSPENSE_LIST_TYPE,
|
|
REACT_MEMO_TYPE,
|
|
REACT_LAZY_TYPE,
|
|
REACT_FUNDAMENTAL_TYPE,
|
|
REACT_RESPONDER_TYPE,
|
|
REACT_SCOPE_TYPE,
|
|
REACT_BLOCK_TYPE,
|
|
REACT_SERVER_BLOCK_TYPE,
|
|
REACT_LEGACY_HIDDEN_TYPE,
|
|
} from 'shared/ReactSymbols';
|
|
|
|
export default function isValidElementType(type: mixed) {
|
|
return (
|
|
typeof type === 'string' ||
|
|
typeof type === 'function' ||
|
|
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
type === REACT_FRAGMENT_TYPE ||
|
|
type === REACT_PROFILER_TYPE ||
|
|
type === REACT_DEBUG_TRACING_MODE_TYPE ||
|
|
type === REACT_STRICT_MODE_TYPE ||
|
|
type === REACT_SUSPENSE_TYPE ||
|
|
type === REACT_SUSPENSE_LIST_TYPE ||
|
|
type === REACT_LEGACY_HIDDEN_TYPE ||
|
|
(typeof type === 'object' &&
|
|
type !== null &&
|
|
(type.$$typeof === REACT_LAZY_TYPE ||
|
|
type.$$typeof === REACT_MEMO_TYPE ||
|
|
type.$$typeof === REACT_PROVIDER_TYPE ||
|
|
type.$$typeof === REACT_CONTEXT_TYPE ||
|
|
type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
type.$$typeof === REACT_FUNDAMENTAL_TYPE ||
|
|
type.$$typeof === REACT_RESPONDER_TYPE ||
|
|
type.$$typeof === REACT_SCOPE_TYPE ||
|
|
type.$$typeof === REACT_BLOCK_TYPE ||
|
|
type[(0: any)] === REACT_SERVER_BLOCK_TYPE))
|
|
);
|
|
}
|