diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 7c6736f5caf4e..24d74bd309faf 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -20,7 +20,6 @@ import type { } from 'react-reconciler/src/ReactInternalTypes'; import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig'; -import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberTransition'; import {NoMode} from 'react-reconciler/src/ReactTypeOfMode'; import ErrorStackParser from 'error-stack-parser'; @@ -62,10 +61,6 @@ type Hook = { next: Hook | null, }; -type TimeoutConfig = {| - timeoutMs: number, -|}; - function getPrimitiveStackCache(): Map> { // This initializes a cache of all primitive hooks so that the top // most stack frames added by calling the primitive hook can be removed. @@ -258,9 +253,7 @@ function useMutableSource( return value; } -function useTransition( - config: SuspenseConfig | null | void, -): [(() => void) => void, boolean] { +function useTransition(): [(() => void) => void, boolean] { // useTransition() composes multiple hooks internally. // Advance the current hook index the same number of times // so that subsequent hooks have the right memoized state. @@ -269,12 +262,12 @@ function useTransition( hookLog.push({ primitive: 'Transition', stackError: new Error(), - value: config, + value: undefined, }); return [callback => {}, false]; } -function useDeferredValue(value: T, config: TimeoutConfig | null | void): T { +function useDeferredValue(value: T): T { // useDeferredValue() composes multiple hooks internally. // Advance the current hook index the same number of times // so that subsequent hooks have the right memoized state. diff --git a/packages/react-dom/src/server/ReactPartialRendererHooks.js b/packages/react-dom/src/server/ReactPartialRendererHooks.js index ec78aac9121b5..49ef413357e7d 100644 --- a/packages/react-dom/src/server/ReactPartialRendererHooks.js +++ b/packages/react-dom/src/server/ReactPartialRendererHooks.js @@ -15,7 +15,6 @@ import type { MutableSourceSubscribeFn, ReactContext, } from 'shared/ReactTypes'; -import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberTransition'; import type PartialRenderer from './ReactPartialRenderer'; import {validateContextBounds} from './ReactPartialRendererContext'; @@ -42,10 +41,6 @@ type Hook = {| next: Hook | null, |}; -type TimeoutConfig = {| - timeoutMs: number, -|}; - type OpaqueIDType = string; let currentlyRenderingComponent: Object | null = null; @@ -468,14 +463,12 @@ function useMutableSource( return getSnapshot(source._source); } -function useDeferredValue(value: T, config: TimeoutConfig | null | void): T { +function useDeferredValue(value: T): T { resolveCurrentlyRenderingComponent(); return value; } -function useTransition( - config: SuspenseConfig | null | void, -): [(callback: () => void) => void, boolean] { +function useTransition(): [(callback: () => void) => void, boolean] { resolveCurrentlyRenderingComponent(); const startTransition = callback => { callback(); diff --git a/packages/react-reconciler/src/ReactFiberHooks.new.js b/packages/react-reconciler/src/ReactFiberHooks.new.js index 820d6972f1045..11de90dffa4e3 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.new.js +++ b/packages/react-reconciler/src/ReactFiberHooks.new.js @@ -16,7 +16,6 @@ import type { import type {Fiber, Dispatcher} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane'; import type {HookEffectTag} from './ReactHookEffectTags'; -import type {SuspenseConfig} from './ReactFiberTransition'; import type {ReactPriorityLevel} from './ReactInternalTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type {OpaqueIDType} from './ReactFiberHostConfig'; @@ -151,10 +150,6 @@ export type Effect = {| export type FunctionComponentUpdateQueue = {|lastEffect: Effect | null|}; -type TimeoutConfig = {| - timeoutMs: number, -|}; - type BasicStateAction = (S => S) | S; type Dispatch = A => void; @@ -1432,10 +1427,7 @@ function updateMemo( return nextValue; } -function mountDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function mountDeferredValue(value: T): T { const [prevValue, setValue] = mountState(value); mountEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1445,14 +1437,11 @@ function mountDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function updateDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function updateDeferredValue(value: T): T { const [prevValue, setValue] = updateState(value); updateEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1462,14 +1451,11 @@ function updateDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function rerenderDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function rerenderDeferredValue(value: T): T { const [prevValue, setValue] = rerenderState(value); updateEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1479,11 +1465,11 @@ function rerenderDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { const priorityLevel = getCurrentPriorityLevel(); if (decoupleUpdatePriorityFromScheduler) { const previousLanePriority = getCurrentUpdateLanePriority(); @@ -1500,7 +1486,9 @@ function startTransition(setPending, config, callback) { }, ); - // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. + // TODO: Can remove this. Was only necessary because we used to give + // different behavior to transitions without a config object. Now they are + // all treated the same. setCurrentUpdateLanePriority(DefaultLanePriority); runWithPriority( @@ -1545,36 +1533,26 @@ function startTransition(setPending, config, callback) { } } -function mountTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { +function mountTransition(): [(() => void) => void, boolean] { const [isPending, setPending] = mountState(false); - const start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); + // The `start` method can be stored on a ref, since `setPending` + // never changes. + const start = startTransition.bind(null, setPending); + mountRef(start); return [start, isPending]; } -function updateTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { - const [isPending, setPending] = updateState(false); - const start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); +function updateTransition(): [(() => void) => void, boolean] { + const [isPending] = updateState(false); + const startRef = updateRef(); + const start: (() => void) => void = (startRef.current: any); return [start, isPending]; } -function rerenderTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { - const [isPending, setPending] = rerenderState(false); - const start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); +function rerenderTransition(): [(() => void) => void, boolean] { + const [isPending] = rerenderState(false); + const startRef = updateRef(); + const start: (() => void) => void = (startRef.current: any); return [start, isPending]; } @@ -1986,17 +1964,15 @@ if (__DEV__) { mountHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2110,17 +2086,15 @@ if (__DEV__) { updateHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2234,17 +2208,15 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource( source: MutableSource, @@ -2359,17 +2331,15 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource( source: MutableSource, @@ -2494,19 +2464,17 @@ if (__DEV__) { mountHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2633,19 +2601,17 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource( source: MutableSource, @@ -2773,19 +2739,17 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource( source: MutableSource, diff --git a/packages/react-reconciler/src/ReactFiberHooks.old.js b/packages/react-reconciler/src/ReactFiberHooks.old.js index 64951ef662670..0e4d4591d705d 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.old.js +++ b/packages/react-reconciler/src/ReactFiberHooks.old.js @@ -16,7 +16,6 @@ import type { import type {Fiber, Dispatcher} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane'; import type {HookEffectTag} from './ReactHookEffectTags'; -import type {SuspenseConfig} from './ReactFiberTransition'; import type {ReactPriorityLevel} from './ReactInternalTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type {OpaqueIDType} from './ReactFiberHostConfig'; @@ -150,10 +149,6 @@ export type Effect = {| export type FunctionComponentUpdateQueue = {|lastEffect: Effect | null|}; -type TimeoutConfig = {| - timeoutMs: number, -|}; - type BasicStateAction = (S => S) | S; type Dispatch = A => void; @@ -1431,10 +1426,7 @@ function updateMemo( return nextValue; } -function mountDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function mountDeferredValue(value: T): T { const [prevValue, setValue] = mountState(value); mountEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1444,14 +1436,11 @@ function mountDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function updateDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function updateDeferredValue(value: T): T { const [prevValue, setValue] = updateState(value); updateEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1461,14 +1450,11 @@ function updateDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function rerenderDeferredValue( - value: T, - config: TimeoutConfig | void | null, -): T { +function rerenderDeferredValue(value: T): T { const [prevValue, setValue] = rerenderState(value); updateEffect(() => { const prevTransition = ReactCurrentBatchConfig.transition; @@ -1478,11 +1464,11 @@ function rerenderDeferredValue( } finally { ReactCurrentBatchConfig.transition = prevTransition; } - }, [value, config]); + }, [value]); return prevValue; } -function startTransition(setPending, config, callback) { +function startTransition(setPending, callback) { const priorityLevel = getCurrentPriorityLevel(); if (decoupleUpdatePriorityFromScheduler) { const previousLanePriority = getCurrentUpdateLanePriority(); @@ -1499,7 +1485,9 @@ function startTransition(setPending, config, callback) { }, ); - // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. + // TODO: Can remove this. Was only necessary because we used to give + // different behavior to transitions without a config object. Now they are + // all treated the same. setCurrentUpdateLanePriority(DefaultLanePriority); runWithPriority( @@ -1544,36 +1532,26 @@ function startTransition(setPending, config, callback) { } } -function mountTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { +function mountTransition(): [(() => void) => void, boolean] { const [isPending, setPending] = mountState(false); - const start = mountCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); + // The `start` method can be stored on a ref, since `setPending` + // never changes. + const start = startTransition.bind(null, setPending); + mountRef(start); return [start, isPending]; } -function updateTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { - const [isPending, setPending] = updateState(false); - const start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); +function updateTransition(): [(() => void) => void, boolean] { + const [isPending] = updateState(false); + const startRef = updateRef(); + const start: (() => void) => void = (startRef.current: any); return [start, isPending]; } -function rerenderTransition( - config: SuspenseConfig | void | null, -): [(() => void) => void, boolean] { - const [isPending, setPending] = rerenderState(false); - const start = updateCallback(startTransition.bind(null, setPending, config), [ - setPending, - config, - ]); +function rerenderTransition(): [(() => void) => void, boolean] { + const [isPending] = rerenderState(false); + const startRef = updateRef(); + const start: (() => void) => void = (startRef.current: any); return [start, isPending]; } @@ -1984,17 +1962,15 @@ if (__DEV__) { mountHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2108,17 +2084,15 @@ if (__DEV__) { updateHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2232,17 +2206,15 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource( source: MutableSource, @@ -2357,17 +2329,15 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource( source: MutableSource, @@ -2492,19 +2462,17 @@ if (__DEV__) { mountHookTypesDev(); return mountDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); mountHookTypesDev(); - return mountDeferredValue(value, config); + return mountDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); mountHookTypesDev(); - return mountTransition(config); + return mountTransition(); }, useMutableSource( source: MutableSource, @@ -2631,19 +2599,17 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); updateHookTypesDev(); - return updateDeferredValue(value, config); + return updateDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); updateHookTypesDev(); - return updateTransition(config); + return updateTransition(); }, useMutableSource( source: MutableSource, @@ -2771,19 +2737,17 @@ if (__DEV__) { updateHookTypesDev(); return updateDebugValue(value, formatterFn); }, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T { + useDeferredValue(value: T): T { currentHookNameInDev = 'useDeferredValue'; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderDeferredValue(value, config); + return rerenderDeferredValue(value); }, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean] { + useTransition(): [(() => void) => void, boolean] { currentHookNameInDev = 'useTransition'; warnInvalidHookAccess(); updateHookTypesDev(); - return rerenderTransition(config); + return rerenderTransition(); }, useMutableSource( source: MutableSource, diff --git a/packages/react-reconciler/src/ReactFiberThrow.new.js b/packages/react-reconciler/src/ReactFiberThrow.new.js index f5c6d2aba4cb5..1e1ca2633c924 100644 --- a/packages/react-reconciler/src/ReactFiberThrow.new.js +++ b/packages/react-reconciler/src/ReactFiberThrow.new.js @@ -314,8 +314,8 @@ function throwException( // that we can show the initial loading state as quickly as possible. // // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. // // If we're already showing a fallback and it gets "retried", allowing us to show // another level, but there's still an inner boundary that would show a fallback, diff --git a/packages/react-reconciler/src/ReactFiberThrow.old.js b/packages/react-reconciler/src/ReactFiberThrow.old.js index e6c27de5e9853..5f37bbb059b74 100644 --- a/packages/react-reconciler/src/ReactFiberThrow.old.js +++ b/packages/react-reconciler/src/ReactFiberThrow.old.js @@ -316,8 +316,8 @@ function throwException( // that we can show the initial loading state as quickly as possible. // // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. // // If we're already showing a fallback and it gets "retried", allowing us to show // another level, but there's still an inner boundary that would show a fallback, diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js index dac8015358f76..f154364f86703 100644 --- a/packages/react-reconciler/src/ReactFiberTransition.js +++ b/packages/react-reconciler/src/ReactFiberTransition.js @@ -9,18 +9,6 @@ import ReactSharedInternals from 'shared/ReactSharedInternals'; -// Deprecated -export type SuspenseConfig = {| - timeoutMs: number, - busyDelayMs?: number, - busyMinDurationMs?: number, -|}; - -// Deprecated -export type TimeoutConfig = {| - timeoutMs: number, -|}; - const {ReactCurrentBatchConfig} = ReactSharedInternals; export const NoTransition = 0; diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index e58a8e1a80f6b..ef7d1ea7633a1 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -27,7 +27,6 @@ import type {RootTag} from './ReactRootTags'; import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig'; import type {Wakeable} from 'shared/ReactTypes'; import type {Interaction} from 'scheduler/src/Tracing'; -import type {SuspenseConfig, TimeoutConfig} from './ReactFiberTransition'; export type ReactPriorityLevel = 99 | 98 | 97 | 96 | 95 | 90; @@ -291,10 +290,8 @@ export type Dispatcher = {| deps: Array | void | null, ): void, useDebugValue(value: T, formatterFn: ?(value: T) => mixed): void, - useDeferredValue(value: T, config: TimeoutConfig | void | null): T, - useTransition( - config: SuspenseConfig | void | null, - ): [(() => void) => void, boolean], + useDeferredValue(value: T): T, + useTransition(): [(() => void) => void, boolean], useMutableSource( source: MutableSource, getSnapshot: MutableSourceGetSnapshotFn, diff --git a/packages/react/src/ReactBatchConfig.js b/packages/react/src/ReactBatchConfig.js index 7e16239671528..c08dac615486c 100644 --- a/packages/react/src/ReactBatchConfig.js +++ b/packages/react/src/ReactBatchConfig.js @@ -7,15 +7,13 @@ * @flow */ -import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberTransition'; - import ReactCurrentBatchConfig from './ReactCurrentBatchConfig'; // This is a copy of startTransition, except if null or undefined is passed, // then updates inside the scope are opted-out of the outer transition scope. // TODO: Deprecated. Remove in favor of startTransition. Figure out how scopes // should nest, and whether we need an API to opt-out nested scopes. -export function withSuspenseConfig(scope: () => void, config?: SuspenseConfig) { +export function withSuspenseConfig(scope: () => void, config?: mixed) { const prevTransition = ReactCurrentBatchConfig.transition; ReactCurrentBatchConfig.transition = config === undefined || config === null ? 0 : 1; diff --git a/packages/react/src/ReactHooks.js b/packages/react/src/ReactHooks.js index d8340e2d14a3e..e1e0879c5f9f2 100644 --- a/packages/react/src/ReactHooks.js +++ b/packages/react/src/ReactHooks.js @@ -151,16 +151,14 @@ export function useDebugValue( export const emptyObject = {}; -export function useTransition( - config: ?Object, -): [(() => void) => void, boolean] { +export function useTransition(): [(() => void) => void, boolean] { const dispatcher = resolveDispatcher(); - return dispatcher.useTransition(config); + return dispatcher.useTransition(); } -export function useDeferredValue(value: T, config: ?Object): T { +export function useDeferredValue(value: T): T { const dispatcher = resolveDispatcher(); - return dispatcher.useDeferredValue(value, config); + return dispatcher.useDeferredValue(value); } export function useOpaqueIdentifier(): OpaqueIDType | void {