mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Put hooks behind feature flag
This commit is contained in:
committed by
Andrew Clark
parent
7bee9fbdd4
commit
105f2de545
@@ -29,6 +29,7 @@ describe('ReactHooks', () => {
|
||||
jest.resetModules();
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
ReactFeatureFlags.enableHooks = true;
|
||||
React = require('react');
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
useState = React.useState;
|
||||
|
||||
@@ -21,6 +21,7 @@ describe('ReactNewContext', () => {
|
||||
jest.resetModules();
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
ReactFeatureFlags.enableHooks = true;
|
||||
React = require('react');
|
||||
useContext = React.useContext;
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
REACT_STRICT_MODE_TYPE,
|
||||
REACT_SUSPENSE_TYPE,
|
||||
} from 'shared/ReactSymbols';
|
||||
import {enableHooks} from 'shared/ReactFeatureFlags';
|
||||
|
||||
import {Component, PureComponent} from './ReactBaseClasses';
|
||||
import {createRef} from './ReactCreateRef';
|
||||
@@ -63,15 +64,6 @@ const React = {
|
||||
lazy,
|
||||
memo,
|
||||
|
||||
useContext,
|
||||
useState,
|
||||
useReducer,
|
||||
useRef,
|
||||
useEffect,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useAPI,
|
||||
|
||||
Fragment: REACT_FRAGMENT_TYPE,
|
||||
StrictMode: REACT_STRICT_MODE_TYPE,
|
||||
Suspense: REACT_SUSPENSE_TYPE,
|
||||
@@ -94,4 +86,15 @@ if (enableStableConcurrentModeAPIs) {
|
||||
React.unstable_Profiler = REACT_PROFILER_TYPE;
|
||||
}
|
||||
|
||||
if (enableHooks) {
|
||||
React.useContext = useContext;
|
||||
React.useState = useState;
|
||||
React.useReducer = useReducer;
|
||||
React.useRef = useRef;
|
||||
React.useEffect = useEffect;
|
||||
React.useCallback = useCallback;
|
||||
React.useMemo = useMemo;
|
||||
React.useAPI = useAPI;
|
||||
}
|
||||
|
||||
export default React;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
|
||||
export const enableHooks = false;
|
||||
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabri
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const enableHooks = false;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
@@ -15,6 +15,7 @@ import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabri
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const enableHooks = false;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
@@ -14,6 +14,7 @@ import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-fb';
|
||||
|
||||
// Re-export dynamic flags from the fbsource version.
|
||||
export const {
|
||||
enableHooks,
|
||||
debugRenderPhaseSideEffects,
|
||||
debugRenderPhaseSideEffectsForStrictMode,
|
||||
warnAboutDeprecatedLifecycles,
|
||||
|
||||
@@ -14,6 +14,7 @@ import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss';
|
||||
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableHooks = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
|
||||
@@ -15,6 +15,7 @@ import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persiste
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const enableHooks = false;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
@@ -15,6 +15,7 @@ import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persiste
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const enableHooks = false;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
|
||||
export const enableProfilerTimer = false;
|
||||
|
||||
@@ -15,6 +15,7 @@ import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persiste
|
||||
export const debugRenderPhaseSideEffects = false;
|
||||
export const debugRenderPhaseSideEffectsForStrictMode = false;
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const enableHooks = false;
|
||||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
|
||||
export const enableProfilerTimer = false;
|
||||
|
||||
@@ -20,6 +20,9 @@ export const {
|
||||
disableInputAttributeSyncing,
|
||||
} = require('ReactFeatureFlags');
|
||||
|
||||
// The rest of the flags are static for better dead code elimination.
|
||||
export const enableHooks = false;
|
||||
|
||||
// In www, we have experimental support for gathering data
|
||||
// from User Timing API calls in production. By default, we
|
||||
// only emit performance.mark/measure calls in __DEV__. But if
|
||||
|
||||
Reference in New Issue
Block a user