mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
This removes defaultProps support for all component types except for
classes. We've chosen to continue supporting defaultProps for classes
because lots of older code relies on it, and unlike function components,
(which can use default params), there's no straightforward alternative.
By implication, it also removes support for setting defaultProps on
`React.lazy` wrapper. So this will not work:
```js
const MyClassComponent = React.lazy(() => import('./MyClassComponent'));
// MyClassComponent is not actually a class; it's a lazy wrapper. So
// defaultProps does not work.
MyClassComponent.defaultProps = { foo: 'bar' };
```
However, if you set the default props on the class itself, then it's
fine.
For classes, this change also moves where defaultProps are resolved.
Previously, defaultProps were resolved by the JSX runtime. This change
is only observable if you introspect a JSX element, which is relatively
rare but does happen.
In other words, previously `<ClassWithDefaultProp />.props.aDefaultProp`
would resolve to the default prop value, but now it does not.
121 lines
3.9 KiB
JavaScript
121 lines
3.9 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and 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 typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
|
|
import typeof * as ExportsType from './ReactFeatureFlags.www';
|
|
import typeof * as DynamicFeatureFlags from './ReactFeatureFlags.www-dynamic';
|
|
|
|
// Re-export dynamic flags from the www version.
|
|
const dynamicFeatureFlags: DynamicFeatureFlags = require('ReactFeatureFlags');
|
|
|
|
export const {
|
|
disableIEWorkarounds,
|
|
enableTrustedTypesIntegration,
|
|
enableDebugTracing,
|
|
enableLazyContextPropagation,
|
|
enableUnifiedSyncLane,
|
|
enableRetryLaneExpiration,
|
|
enableTransitionTracing,
|
|
enableDeferRootSchedulingToMicrotask,
|
|
alwaysThrottleRetries,
|
|
enableDO_NOT_USE_disableStrictPassiveEffect,
|
|
disableSchedulerTimeoutInWorkLoop,
|
|
enableUseDeferredValueInitialArg,
|
|
retryLaneExpirationMs,
|
|
syncLaneExpirationMs,
|
|
transitionLaneExpirationMs,
|
|
enableInfiniteRenderLoopDetection,
|
|
enableRenderableContext,
|
|
enableRefAsProp,
|
|
favorSafetyOverHydrationPerf,
|
|
disableDefaultPropsExceptForClasses,
|
|
} = dynamicFeatureFlags;
|
|
|
|
// On WWW, __EXPERIMENTAL__ is used for a new modern build.
|
|
// It's not used anywhere in production yet.
|
|
|
|
export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;
|
|
export const enableProfilerTimer = __PROFILE__;
|
|
export const enableProfilerCommitHooks = __PROFILE__;
|
|
export const enableProfilerNestedUpdatePhase = __PROFILE__;
|
|
export const enableUpdaterTracking = __PROFILE__;
|
|
|
|
export const enableSuspenseAvoidThisFallback = true;
|
|
export const enableSuspenseAvoidThisFallbackFizz = false;
|
|
|
|
export const enableCPUSuspense = true;
|
|
export const enableUseMemoCacheHook = true;
|
|
export const enableUseEffectEventHook = true;
|
|
export const enableFilterEmptyStringAttributesDOM = true;
|
|
export const enableAsyncActions = true;
|
|
export const disableInputAttributeSyncing = false;
|
|
export const enableLegacyFBSupport = true;
|
|
|
|
// Logs additional User Timing API marks for use with an experimental profiling tool.
|
|
export const enableSchedulingProfiler: boolean =
|
|
__PROFILE__ && dynamicFeatureFlags.enableSchedulingProfiler;
|
|
|
|
export const disableLegacyContext = __EXPERIMENTAL__;
|
|
export const enableGetInspectorDataForInstanceInProduction = false;
|
|
|
|
export const enableCache = true;
|
|
export const enableLegacyCache = true;
|
|
export const enableFetchInstrumentation = false;
|
|
|
|
export const enableBinaryFlight = false;
|
|
export const enableTaint = false;
|
|
|
|
export const enablePostpone = false;
|
|
|
|
// TODO: www currently relies on this feature. It's disabled in open source.
|
|
// Need to remove it.
|
|
export const disableCommentsAsDOMContainers = false;
|
|
|
|
export const enableCreateEventHandleAPI = true;
|
|
|
|
export const enableScopeAPI = true;
|
|
|
|
export const enableSuspenseCallback = true;
|
|
|
|
export const enableLegacyHidden = true;
|
|
|
|
export const enableComponentStackLocations = true;
|
|
|
|
export const disableTextareaChildren = __EXPERIMENTAL__;
|
|
|
|
export const allowConcurrentByDefault = true;
|
|
|
|
export const consoleManagedByDevToolsDuringStrictMode = true;
|
|
|
|
export const enableFizzExternalRuntime = true;
|
|
|
|
export const forceConcurrentByDefaultForTesting = false;
|
|
|
|
export const passChildrenWhenCloningPersistedNodes = false;
|
|
|
|
export const enableAsyncDebugInfo = false;
|
|
export const disableClientCache = true;
|
|
|
|
export const enableServerComponentKeys = true;
|
|
export const enableServerComponentLogs = true;
|
|
|
|
export const enableReactTestRendererWarning = false;
|
|
export const useModernStrictMode = true;
|
|
|
|
// TODO: Roll out with GK. Don't keep as dynamic flag for too long, though,
|
|
// because JSX is an extremely hot path.
|
|
export const disableStringRefs = false;
|
|
|
|
export const disableLegacyMode = __EXPERIMENTAL__;
|
|
|
|
export const disableDOMTestUtils = false;
|
|
|
|
// Flow magic to verify the exports of this file match the original version.
|
|
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
|