diff --git a/packages/react-art/src/ReactFiberConfigART.js b/packages/react-art/src/ReactFiberConfigART.js index e9d18a3081010..db4e8015df131 100644 --- a/packages/react-art/src/ReactFiberConfigART.js +++ b/packages/react-art/src/ReactFiberConfigART.js @@ -560,15 +560,7 @@ export function createViewTransitionInstance( export type GestureTimeline = null; export function getCurrentGestureOffset(provider: GestureTimeline): number { - throw new Error('useSwipeTransition is not yet supported in react-art.'); -} - -export function subscribeToGestureDirection( - provider: GestureTimeline, - currentOffset: number, - directionCallback: (direction: boolean) => void, -): () => void { - throw new Error('useSwipeTransition is not yet supported in react-art.'); + throw new Error('startGestureTransition is not yet supported in react-art.'); } export function clearContainer(container) { diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 5cf93c587de11..8242b27d4e5be 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -14,7 +14,6 @@ import type { Usable, Thenable, ReactDebugInfo, - StartGesture, } from 'shared/ReactTypes'; import type { ContextDependency, @@ -132,9 +131,6 @@ function getPrimitiveStackCache(): Map> { if (typeof Dispatcher.useEffectEvent === 'function') { Dispatcher.useEffectEvent((args: empty) => {}); } - if (typeof Dispatcher.useSwipeTransition === 'function') { - Dispatcher.useSwipeTransition(null, null, null); - } } finally { readHookLog = hookLog; hookLog = []; @@ -753,23 +749,6 @@ function useEffectEvent) => mixed>(callback: F): F { return callback; } -function useSwipeTransition( - previous: T, - current: T, - next: T, -): [T, StartGesture] { - nextHook(); - hookLog.push({ - displayName: null, - primitive: 'SwipeTransition', - stackError: new Error(), - value: current, - debugInfo: null, - dispatcherHookName: 'SwipeTransition', - }); - return [current, () => () => {}]; -} - const Dispatcher: DispatcherType = { readContext, @@ -796,7 +775,6 @@ const Dispatcher: DispatcherType = { useMemoCache, useCacheRefresh, useEffectEvent, - useSwipeTransition, }; // create a proxy to throw a custom error diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index e6b54a1e5e522..0e2696d1e6a59 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1358,7 +1358,9 @@ export function cloneRootViewTransitionContainer( const containerParent = containerInstance.parentNode; if (containerParent === null) { - throw new Error('Cannot use a useSwipeTransition() in a detached root.'); + throw new Error( + 'Cannot use a startGestureTransition() on a detached root.', + ); } const clone: HTMLElement = containerInstance.cloneNode(false); @@ -1464,7 +1466,9 @@ export function removeRootViewTransitionClone( } const containerParent = containerInstance.parentNode; if (containerParent === null) { - throw new Error('Cannot use a useSwipeTransition() in a detached root.'); + throw new Error( + 'Cannot use a startGestureTransition() on a detached root.', + ); } // We assume that the clone is still within the same parent. containerParent.removeChild(clone); @@ -2172,50 +2176,6 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number { return typeof time === 'number' ? time : time.value; } -export function subscribeToGestureDirection( - provider: GestureTimeline, - currentOffset: number, - directionCallback: (direction: boolean) => void, -): () => void { - if ( - typeof ScrollTimeline === 'function' && - provider instanceof ScrollTimeline - ) { - // For ScrollTimeline we optimize to only update the current time on scroll events. - const element = provider.source; - const scrollCallback = () => { - const newTime = provider.currentTime; - if (newTime !== null) { - const newValue = typeof newTime === 'number' ? newTime : newTime.value; - if (newValue !== currentOffset) { - directionCallback(newValue > currentOffset); - } - } - }; - element.addEventListener('scroll', scrollCallback, false); - return () => { - element.removeEventListener('scroll', scrollCallback, false); - }; - } else { - // For other AnimationTimelines, such as DocumentTimeline, we just update every rAF. - // TODO: Optimize ViewTimeline using an IntersectionObserver if it becomes common. - const rafCallback = () => { - const newTime = provider.currentTime; - if (newTime !== null) { - const newValue = typeof newTime === 'number' ? newTime : newTime.value; - if (newValue !== currentOffset) { - directionCallback(newValue > currentOffset); - } - } - callbackID = requestAnimationFrame(rafCallback); - }; - let callbackID = requestAnimationFrame(rafCallback); - return () => { - cancelAnimationFrame(callbackID); - }; - } -} - type EventListenerOptionsOrUseCapture = | boolean | { diff --git a/packages/react-native-renderer/src/ReactFiberConfigNative.js b/packages/react-native-renderer/src/ReactFiberConfigNative.js index 876540a42de06..b278310c8b20c 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigNative.js +++ b/packages/react-native-renderer/src/ReactFiberConfigNative.js @@ -692,15 +692,9 @@ export function createViewTransitionInstance( export type GestureTimeline = null; export function getCurrentGestureOffset(provider: GestureTimeline): number { - throw new Error('useSwipeTransition is not yet supported in React Native.'); -} - -export function subscribeToGestureDirection( - provider: GestureTimeline, - currentOffset: number, - directionCallback: (direction: boolean) => void, -): () => void { - throw new Error('useSwipeTransition is not yet supported in React Native.'); + throw new Error( + 'startGestureTransition is not yet supported in React Native.', + ); } export function clearContainer(container: Container): void { diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index d452e8e10e378..405edb7c53293 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -865,14 +865,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { return 0; }, - subscribeToGestureDirection( - provider: GestureTimeline, - currentOffset: number, - directionCallback: (direction: boolean) => void, - ): () => void { - return () => {}; - }, - resetTextContent(instance: Instance): void { instance.text = null; }, diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js index ee44233b8f8d2..28f9ff3e3555d 100644 --- a/packages/react-reconciler/src/ReactFiberApplyGesture.js +++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js @@ -412,7 +412,7 @@ function recursivelyInsertNewFiber( // had any effect. if (finishedWork.flags & Update) { console.error( - 'useSwipeTransition() caused something to render a new <%s>. ' + + 'startGestureTransition() caused something to render a new <%s>. ' + 'This is not possible in the current implementation. ' + "Make sure that the swipe doesn't mount any new <%s> elements.", finishedWork.type, @@ -789,7 +789,7 @@ function insertDestinationClonesOfFiber( commitUpdate(instance, type, oldProps, newProps, finishedWork); if (viewTransitionMutationContext) { console.error( - 'useSwipeTransition() caused something to mutate <%s>. ' + + 'startGestureTransition() caused something to mutate <%s>. ' + 'This is not possible in the current implementation. ' + "Make sure that the swipe doesn't update any state which " + 'causes <%s> to change.', @@ -977,10 +977,10 @@ export function insertDestinationClones( if (!didWarnForRootClone) { didWarnForRootClone = true; console.warn( - 'useSwipeTransition() caused something to mutate or relayout the root. ' + + 'startGestureTransition() caused something to mutate or relayout the root. ' + 'This currently requires a clone of the whole document. Make sure to ' + 'add a directly around an absolutely positioned DOM node ' + - 'to minimize the impact of any changes caused by the Swipe Transition.', + 'to minimize the impact of any changes caused by the Gesture Transition.', ); } } diff --git a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js index 859e553ccbcb6..1fcf1509f10d9 100644 --- a/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js +++ b/packages/react-reconciler/src/ReactFiberConcurrentUpdates.js @@ -24,14 +24,7 @@ import { throwIfInfiniteUpdateLoopDetected, getWorkInProgressRoot, } from './ReactFiberWorkLoop'; -import { - NoLane, - NoLanes, - mergeLanes, - markHiddenUpdate, - markRootUpdated, - GestureLane, -} from './ReactFiberLane'; +import {NoLane, NoLanes, mergeLanes, markHiddenUpdate} from './ReactFiberLane'; import {NoFlags, Placement, Hydrating} from './ReactFiberFlags'; import {HostRoot, OffscreenComponent} from './ReactWorkTags'; import {OffscreenVisible} from './ReactFiberActivityComponent'; @@ -176,25 +169,6 @@ export function enqueueConcurrentRenderForLane( return getRootForUpdatedFiber(fiber); } -export function enqueueGestureRender(fiber: Fiber): FiberRoot | null { - // We can't use the concurrent queuing for these so this is basically just a - // short cut for marking the lane on the parent path. It is possible for a - // gesture render to suspend and then in the gap get another gesture starting. - // However, marking the lane doesn't make much different in this case because - // it would have to call startGesture with the same exact provider as was - // already rendering. Because otherwise it has no effect on the Hook itself. - // TODO: We could potentially solve this case by popping a ScheduledGesture - // off the root's queue while we're rendering it so that it can't dedupe - // and so new startGesture with the same provider would create a new - // ScheduledGesture which goes into a separate render pass anyway. - // This is such an edge case it probably doesn't matter much. - const root = markUpdateLaneFromFiberToRoot(fiber, null, GestureLane); - if (root !== null) { - markRootUpdated(root, GestureLane); - } - return root; -} - // Calling this function outside this module should only be done for backwards // compatibility and should always be accompanied by a warning. export function unsafe_markUpdateLaneFromFiberToRoot( diff --git a/packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js b/packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js index bb347defe8463..09e64b0aa0854 100644 --- a/packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js +++ b/packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js @@ -58,4 +58,3 @@ export type ViewTransitionInstance = null | {name: string, ...}; export const createViewTransitionInstance = shim; export type GestureTimeline = any; export const getCurrentGestureOffset = shim; -export const subscribeToGestureDirection = shim; diff --git a/packages/react-reconciler/src/ReactFiberGestureScheduler.js b/packages/react-reconciler/src/ReactFiberGestureScheduler.js index be322cf00ed8b..4d28abf80e337 100644 --- a/packages/react-reconciler/src/ReactFiberGestureScheduler.js +++ b/packages/react-reconciler/src/ReactFiberGestureScheduler.js @@ -17,11 +17,7 @@ import { includesTransitionLane, } from './ReactFiberLane'; import {ensureRootIsScheduled} from './ReactFiberRootScheduler'; -import { - subscribeToGestureDirection, - getCurrentGestureOffset, - stopViewTransition, -} from './ReactFiberConfig'; +import {getCurrentGestureOffset, stopViewTransition} from './ReactFiberConfig'; // This type keeps track of any scheduled or active gestures. export type ScheduledGesture = { @@ -31,85 +27,11 @@ export type ScheduledGesture = { rangePrevious: number, // The end along the timeline where the previous state is reached. rangeCurrent: number, // The starting offset along the timeline. rangeNext: number, // The end along the timeline where the next state is reached. - cancel: () => void, // Cancel the subscription to direction change. // TODO: Delete this. running: null | RunningViewTransition, // Used to cancel the running transition after we're done. prev: null | ScheduledGesture, // The previous scheduled gesture in the queue for this root. next: null | ScheduledGesture, // The next scheduled gesture in the queue for this root. }; -// TODO: Delete this when deleting useSwipeTransition. -export function scheduleGestureLegacy( - root: FiberRoot, - provider: GestureTimeline, - initialDirection: boolean, - rangePrevious: number, - rangeCurrent: number, - rangeNext: number, -): ScheduledGesture { - let prev = root.pendingGestures; - while (prev !== null) { - if (prev.provider === provider) { - // Existing instance found. - prev.count++; - return prev; - } - const next = prev.next; - if (next === null) { - break; - } - prev = next; - } - const isFlippedDirection = rangePrevious > rangeNext; - // Add new instance to the end of the queue. - const cancel = subscribeToGestureDirection( - provider, - rangeCurrent, - (direction: boolean) => { - if (isFlippedDirection) { - direction = !direction; - } - if (gesture.direction !== direction) { - gesture.direction = direction; - if (gesture.prev === null && root.pendingGestures !== gesture) { - // This gesture is not in the schedule, meaning it was already rendered. - // We need to rerender in the new direction. Insert it into the first slot - // in case other gestures are queued after the on-going one. - const existing = root.pendingGestures; - gesture.next = existing; - if (existing !== null) { - existing.prev = gesture; - } - root.pendingGestures = gesture; - // Schedule the lane on the root. The Fibers will already be marked as - // long as the gesture is active on that Hook. - root.pendingLanes |= GestureLane; - ensureRootIsScheduled(root); - } - // TODO: If we're currently rendering this gesture, we need to restart it. - } - }, - ); - const gesture: ScheduledGesture = { - provider: provider, - count: 1, - direction: initialDirection, - rangePrevious: rangePrevious, - rangeCurrent: rangeCurrent, - rangeNext: rangeNext, - cancel: cancel, - running: null, - prev: prev, - next: null, - }; - if (prev === null) { - root.pendingGestures = gesture; - } else { - prev.next = gesture; - } - ensureRootIsScheduled(root); - return gesture; -} - export function scheduleGesture( root: FiberRoot, provider: GestureTimeline, @@ -133,7 +55,6 @@ export function scheduleGesture( rangePrevious: -1, rangeCurrent: -1, rangeNext: -1, - cancel: () => {}, // TODO: Delete this with useSwipeTransition. running: null, prev: prev, next: null, @@ -210,8 +131,6 @@ export function cancelScheduledGesture( ): void { gesture.count--; if (gesture.count === 0) { - const cancelDirectionSubscription = gesture.cancel; - cancelDirectionSubscription(); // Delete the scheduled gesture from the pending queue. deleteScheduledGesture(root, gesture); // TODO: If we're currently rendering this gesture, we need to restart the render diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 24728a68ffa63..c8136f8fa03b2 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -14,9 +14,6 @@ import type { Thenable, RejectedThenable, Awaited, - StartGesture, - GestureProvider, - GestureOptions, } from 'shared/ReactTypes'; import type { Fiber, @@ -28,7 +25,7 @@ import type { import type {Lanes, Lane} from './ReactFiberLane'; import type {HookFlags} from './ReactHookEffectTags'; import type {Flags} from './ReactFiberFlags'; -import type {TransitionStatus, GestureTimeline} from './ReactFiberConfig'; +import type {TransitionStatus} from './ReactFiberConfig'; import type {ScheduledGesture} from './ReactFiberGestureScheduler'; import { @@ -36,7 +33,6 @@ import { NotPendingTransition as NoPendingHostTransition, setCurrentUpdatePriority, getCurrentUpdatePriority, - getCurrentGestureOffset, } from './ReactFiberConfig'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import { @@ -46,7 +42,7 @@ import { enableLegacyCache, disableLegacyMode, enableNoCloningMemoCache, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import { REACT_CONTEXT_TYPE, @@ -137,7 +133,6 @@ import { enqueueConcurrentHookUpdate, enqueueConcurrentHookUpdateAndEagerlyBailout, enqueueConcurrentRenderForLane, - enqueueGestureRender, } from './ReactFiberConcurrentUpdates'; import {getTreeId} from './ReactFiberTreeContext'; import {now} from './Scheduler'; @@ -161,11 +156,7 @@ import {requestCurrentTransition} from './ReactFiberTransition'; import {callComponentInDEV} from './ReactFiberCallUserSpace'; -import { - scheduleGesture, - scheduleGestureLegacy, - cancelScheduledGesture, -} from './ReactFiberGestureScheduler'; +import {scheduleGesture} from './ReactFiberGestureScheduler'; export type Update = { lane: Lane, @@ -174,7 +165,7 @@ export type Update = { hasEagerState: boolean, eagerState: S | null, next: Update, - gesture: null | ScheduledGesture, // enableSwipeTransition + gesture: null | ScheduledGesture, // enableGestureTransition }; export type UpdateQueue = { @@ -1383,7 +1374,7 @@ function updateReducerImpl( ? !isSubsetOfLanes(getWorkInProgressRootRenderLanes(), updateLane) : !isSubsetOfLanes(renderLanes, updateLane); - if (enableSwipeTransition && updateLane === GestureLane) { + if (enableGestureTransition && updateLane === GestureLane) { // This is a gesture optimistic update. It should only be considered as part of the // rendered state while rendering the gesture lane and if the rendering the associated // ScheduledGesture. @@ -2168,7 +2159,7 @@ function runActionStateAction( // This is a fork of startTransition const prevTransition = ReactSharedInternals.T; const currentTransition: Transition = ({}: any); - if (enableSwipeTransition) { + if (enableGestureTransition) { currentTransition.gesture = null; } if (enableTransitionTracing) { @@ -3050,7 +3041,7 @@ function startTransition( const prevTransition = ReactSharedInternals.T; const currentTransition: Transition = ({}: any); - if (enableSwipeTransition) { + if (enableGestureTransition) { currentTransition.gesture = null; } if (enableTransitionTracing) { @@ -3278,7 +3269,7 @@ export function requestFormReset(formFiber: Fiber) { 'fix, move to an action, or wrap with startTransition.', ); } - } else if (enableSwipeTransition && transition.gesture) { + } else if (enableGestureTransition && transition.gesture) { throw new Error( 'Cannot requestFormReset() inside a startGestureTransition. ' + 'There should be no side-effects associated with starting a ' + @@ -3655,7 +3646,7 @@ function dispatchOptimisticSetState( // For regular Transitions an optimistic update commits synchronously. // For gesture Transitions an optimistic update commits on the GestureLane. const lane = - enableSwipeTransition && transition !== null && transition.gesture + enableGestureTransition && transition !== null && transition.gesture ? GestureLane : SyncLane; const update: Update = { @@ -3696,7 +3687,7 @@ function dispatchOptimisticSetState( scheduleUpdateOnFiber(root, fiber, lane); // Optimistic updates are always synchronous, so we don't need to call // entangleTransitionUpdate here. - if (enableSwipeTransition && transition !== null) { + if (enableGestureTransition && transition !== null) { const provider = transition.gesture; if (provider !== null) { // If this was a gesture, ensure we have a scheduled gesture and that @@ -3770,183 +3761,6 @@ function markUpdateInDevTools(fiber: Fiber, lane: Lane, action: A): void { } } -type SwipeTransitionGestureUpdate = { - gesture: ScheduledGesture, - prev: SwipeTransitionGestureUpdate | null, - next: SwipeTransitionGestureUpdate | null, -}; - -type SwipeTransitionUpdateQueue = { - pending: null | SwipeTransitionGestureUpdate, - dispatch: StartGesture, - initialDirection: boolean, -}; - -function startGesture( - fiber: Fiber, - queue: SwipeTransitionUpdateQueue, - gestureProvider: GestureProvider, - gestureOptions?: GestureOptions, -): () => void { - const root = enqueueGestureRender(fiber); - if (root === null) { - // Already unmounted. - // TODO: Should we warn here about starting on an unmounted Fiber? - return function cancelGesture() { - // Noop. - }; - } - const gestureTimeline: GestureTimeline = gestureProvider; - const currentOffset = getCurrentGestureOffset(gestureTimeline); - const range = gestureOptions && gestureOptions.range; - const rangePrevious: number = range ? range[0] : 0; // If no range is provider we assume it's the starting point of the range. - const rangeCurrent: number = range ? range[1] : currentOffset; - const rangeNext: number = range ? range[2] : 100; // If no range is provider we assume it's the starting point of the range. - if (__DEV__) { - if ( - (rangePrevious > rangeCurrent && rangeNext > rangeCurrent) || - (rangePrevious < rangeCurrent && rangeNext < rangeCurrent) - ) { - console.error( - 'The range of a gesture needs "previous" and "next" to be on either side of ' + - 'the "current" offset. Both cannot be above current and both cannot be below current.', - ); - } - } - const isFlippedDirection = rangePrevious > rangeNext; - const initialDirection = - // If a range is specified we can imply initial direction if it's not the current - // value such as if the gesture starts after it has already moved. - currentOffset < rangeCurrent - ? isFlippedDirection - : currentOffset > rangeCurrent - ? !isFlippedDirection - : // Otherwise, look for an explicit option. - gestureOptions && gestureOptions.direction === 'next' - ? true - : gestureOptions && gestureOptions.direction === 'previous' - ? false - : // If no option is specified, imply from the values specified. - queue.initialDirection; - const scheduledGesture = scheduleGestureLegacy( - root, - gestureTimeline, - initialDirection, - rangePrevious, - rangeCurrent, - rangeNext, - ); - // Add this particular instance to the queue. - // We add multiple of the same timeline even if they get batched so - // that if we cancel one but not the other we can keep track of this. - // Order doesn't matter but we insert in the beginning to avoid two fields. - const update: SwipeTransitionGestureUpdate = { - gesture: scheduledGesture, - prev: null, - next: queue.pending, - }; - if (queue.pending !== null) { - queue.pending.prev = update; - } - queue.pending = update; - return function cancelGesture(): void { - if (update.prev === null) { - if (queue.pending === update) { - queue.pending = update.next; - } else { - // This was already cancelled. Avoid double decrementing if someone calls this twice by accident. - // TODO: Should we warn here about double cancelling? - return; - } - } else { - update.prev.next = update.next; - if (update.next !== null) { - update.next.prev = update.prev; - } - update.prev = null; - update.next = null; - } - const cancelledGestured = update.gesture; - // Decrement ref count of the root schedule. - cancelScheduledGesture(root, cancelledGestured); - }; -} - -function mountSwipeTransition( - previous: T, - current: T, - next: T, -): [T, StartGesture] { - const queue: SwipeTransitionUpdateQueue = { - pending: null, - dispatch: (null: any), - initialDirection: previous === current, - }; - const startGestureOnHook: StartGesture = (queue.dispatch = (startGesture.bind( - null, - currentlyRenderingFiber, - queue, - ): any)); - const hook = mountWorkInProgressHook(); - hook.queue = queue; - return [current, startGestureOnHook]; -} - -function updateSwipeTransition( - previous: T, - current: T, - next: T, -): [T, StartGesture] { - const hook = updateWorkInProgressHook(); - const queue: SwipeTransitionUpdateQueue = hook.queue; - const startGestureOnHook: StartGesture = queue.dispatch; - const rootRenderLanes = getWorkInProgressRootRenderLanes(); - let value = current; - if (queue.pending !== null) { - if (isGestureRender(rootRenderLanes)) { - // We're inside a gesture render. We'll traverse the queue to see if - // this specific Hook is part of this gesture and, if so, which - // direction to render. - const root: FiberRoot | null = getWorkInProgressRoot(); - if (root === null) { - throw new Error( - 'Expected a work-in-progress root. This is a bug in React. Please file an issue.', - ); - } - // We assume that the currently rendering gesture is the one first in the queue. - const rootRenderGesture = root.pendingGestures; - if (rootRenderGesture !== null) { - let update = queue.pending; - while (update !== null) { - if (rootRenderGesture === update.gesture) { - // We had a match, meaning we're currently rendering a direction of this - // hook for this gesture. - value = rootRenderGesture.direction ? next : previous; - break; - } - update = update.next; - } - } - // This lane cannot be cleared as long as we have active gestures. - markWorkInProgressReceivedUpdate(); - } - // As long as there are any active gestures we need to leave the lane on - // in case we need to render it later. Since a gesture render doesn't commit - // the only time it really fully gets cleared is if something else rerenders - // this component after all the active gestures has cleared. - currentlyRenderingFiber.lanes = mergeLanes( - currentlyRenderingFiber.lanes, - GestureLane, - ); - } - // By default, we don't know which direction we should start until a movement - // has happened. However, if one direction has the same value as current we - // know that it's probably not that direction since it won't do anything anyway. - // TODO: Add an explicit option to provide this. - queue.initialDirection = previous === current; - return [value, startGestureOnHook]; -} - export const ContextOnlyDispatcher: Dispatcher = { readContext, @@ -3976,10 +3790,6 @@ export const ContextOnlyDispatcher: Dispatcher = { if (enableUseEffectEventHook) { (ContextOnlyDispatcher: Dispatcher).useEffectEvent = throwInvalidHookError; } -if (enableSwipeTransition) { - (ContextOnlyDispatcher: Dispatcher).useSwipeTransition = - throwInvalidHookError; -} const HooksDispatcherOnMount: Dispatcher = { readContext, @@ -4010,10 +3820,6 @@ const HooksDispatcherOnMount: Dispatcher = { if (enableUseEffectEventHook) { (HooksDispatcherOnMount: Dispatcher).useEffectEvent = mountEvent; } -if (enableSwipeTransition) { - (HooksDispatcherOnMount: Dispatcher).useSwipeTransition = - mountSwipeTransition; -} const HooksDispatcherOnUpdate: Dispatcher = { readContext, @@ -4044,10 +3850,6 @@ const HooksDispatcherOnUpdate: Dispatcher = { if (enableUseEffectEventHook) { (HooksDispatcherOnUpdate: Dispatcher).useEffectEvent = updateEvent; } -if (enableSwipeTransition) { - (HooksDispatcherOnUpdate: Dispatcher).useSwipeTransition = - updateSwipeTransition; -} const HooksDispatcherOnRerender: Dispatcher = { readContext, @@ -4078,10 +3880,6 @@ const HooksDispatcherOnRerender: Dispatcher = { if (enableUseEffectEventHook) { (HooksDispatcherOnRerender: Dispatcher).useEffectEvent = updateEvent; } -if (enableSwipeTransition) { - (HooksDispatcherOnRerender: Dispatcher).useSwipeTransition = - updateSwipeTransition; -} let HooksDispatcherOnMountInDEV: Dispatcher | null = null; let HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher | null = null; @@ -4282,18 +4080,6 @@ if (__DEV__) { return mountEvent(callback); }; } - if (enableSwipeTransition) { - (HooksDispatcherOnMountInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - mountHookTypesDev(); - return mountSwipeTransition(previous, current, next); - }; - } HooksDispatcherOnMountWithHookTypesInDEV = { readContext(context: ReactContext): T { @@ -4461,18 +4247,6 @@ if (__DEV__) { return mountEvent(callback); }; } - if (enableSwipeTransition) { - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - updateHookTypesDev(); - return updateSwipeTransition(previous, current, next); - }; - } HooksDispatcherOnUpdateInDEV = { readContext(context: ReactContext): T { @@ -4640,18 +4414,6 @@ if (__DEV__) { return updateEvent(callback); }; } - if (enableSwipeTransition) { - (HooksDispatcherOnUpdateInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - updateHookTypesDev(); - return updateSwipeTransition(previous, current, next); - }; - } HooksDispatcherOnRerenderInDEV = { readContext(context: ReactContext): T { @@ -4819,18 +4581,6 @@ if (__DEV__) { return updateEvent(callback); }; } - if (enableSwipeTransition) { - (HooksDispatcherOnRerenderInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - updateHookTypesDev(); - return updateSwipeTransition(previous, current, next); - }; - } InvalidNestedHooksDispatcherOnMountInDEV = { readContext(context: ReactContext): T { @@ -5023,19 +4773,6 @@ if (__DEV__) { return mountEvent(callback); }; } - if (enableSwipeTransition) { - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - warnInvalidHookAccess(); - mountHookTypesDev(); - return mountSwipeTransition(previous, current, next); - }; - } InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext(context: ReactContext): T { @@ -5228,19 +4965,6 @@ if (__DEV__) { return updateEvent(callback); }; } - if (enableSwipeTransition) { - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - warnInvalidHookAccess(); - updateHookTypesDev(); - return updateSwipeTransition(previous, current, next); - }; - } InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext(context: ReactContext): T { @@ -5433,17 +5157,4 @@ if (__DEV__) { return updateEvent(callback); }; } - if (enableSwipeTransition) { - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useSwipeTransition = - function useSwipeTransition( - previous: T, - current: T, - next: T, - ): [T, StartGesture] { - currentHookNameInDev = 'useSwipeTransition'; - warnInvalidHookAccess(); - updateHookTypesDev(); - return updateSwipeTransition(previous, current, next); - }; - } } diff --git a/packages/react-reconciler/src/ReactFiberRoot.js b/packages/react-reconciler/src/ReactFiberRoot.js index 1e1ac1cab220a..e8b2dbf205382 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.js +++ b/packages/react-reconciler/src/ReactFiberRoot.js @@ -33,7 +33,7 @@ import { enableUpdaterTracking, enableTransitionTracing, disableLegacyMode, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue'; import {LegacyRoot, ConcurrentRoot} from './ReactRootTags'; @@ -98,7 +98,7 @@ function FiberRootNode( this.formState = formState; - if (enableSwipeTransition) { + if (enableGestureTransition) { this.pendingGestures = null; this.stoppingGestures = null; this.gestureClone = null; diff --git a/packages/react-reconciler/src/ReactFiberRootScheduler.js b/packages/react-reconciler/src/ReactFiberRootScheduler.js index 7e175fd247ab6..3415d1795a9a2 100644 --- a/packages/react-reconciler/src/ReactFiberRootScheduler.js +++ b/packages/react-reconciler/src/ReactFiberRootScheduler.js @@ -20,7 +20,7 @@ import { enableComponentPerformanceTrack, enableSiblingPrerendering, enableYieldingBeforePassive, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import { NoLane, @@ -214,7 +214,7 @@ function flushSyncWorkAcrossRoots_impl( ); if ( (includesSyncLane(nextLanes) || - (enableSwipeTransition && isGestureRender(nextLanes))) && + (enableGestureTransition && isGestureRender(nextLanes))) && !checkIfRootIsPrerendering(root, nextLanes) ) { // This root has pending sync work. Flush it now. @@ -300,7 +300,7 @@ function processRootScheduleInMicrotask() { // Common case: we're not treating any extra lanes as synchronous, so we // can just check if the next lanes are sync. includesSyncLane(nextLanes) || - (enableSwipeTransition && isGestureRender(nextLanes)) + (enableGestureTransition && isGestureRender(nextLanes)) ) { mightHavePendingSyncWork = true; } diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js index f96667a943dd6..4bb123205e1b3 100644 --- a/packages/react-reconciler/src/ReactFiberTransition.js +++ b/packages/react-reconciler/src/ReactFiberTransition.js @@ -20,7 +20,7 @@ import type {ScheduledGesture} from './ReactFiberGestureScheduler'; import { enableTransitionTracing, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import {isPrimaryRenderer} from './ReactFiberConfig'; import {createCursor, push, pop} from './ReactFiberStack'; @@ -106,7 +106,7 @@ function chainGestureCancellation( }; } -if (enableSwipeTransition) { +if (enableGestureTransition) { const prevOnStartGestureTransitionFinish = ReactSharedInternals.G; ReactSharedInternals.G = function onStartGestureTransitionFinishForReconciler( transition: Transition, diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index 4750e35552b9f..9dc9c7fe567ef 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -51,7 +51,7 @@ import { enableYieldingBeforePassive, enableThrottledScheduling, enableViewTransition, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import {resetOwnerStackLimit} from 'shared/ReactOwnerStackReset'; import ReactSharedInternals from 'shared/ReactSharedInternals'; @@ -753,7 +753,7 @@ export function requestUpdateLane(fiber: Fiber): Lane { const transition = requestCurrentTransition(); if (transition !== null) { - if (enableSwipeTransition) { + if (enableGestureTransition) { if (transition.gesture) { throw new Error( 'Cannot setState on regular state inside a startGestureTransition. ' + @@ -1451,7 +1451,7 @@ function commitRootWhenReady( const subtreeFlags = finishedWork.subtreeFlags; const isViewTransitionEligible = enableViewTransition && includesOnlyViewTransitionEligibleLanes(lanes); // TODO: Use a subtreeFlag to optimize. - const isGestureTransition = enableSwipeTransition && isGestureRender(lanes); + const isGestureTransition = enableGestureTransition && isGestureRender(lanes); const maySuspendCommit = subtreeFlags & ShouldSuspendCommit || (subtreeFlags & BothVisibilityAndMaySuspendCommit) === @@ -1470,7 +1470,7 @@ function commitRootWhenReady( if (isViewTransitionEligible || isGestureTransition) { // If we're stopping gestures we don't have to wait for any pending // view transition. We'll stop it when we commit. - if (!enableSwipeTransition || root.stoppingGestures === null) { + if (!enableGestureTransition || root.stoppingGestures === null) { suspendOnActiveViewTransition(root.containerInfo); } } @@ -3297,7 +3297,7 @@ function commitRoot( if (enableSchedulingProfiler) { markCommitStopped(); } - if (enableSwipeTransition) { + if (enableGestureTransition) { // Stop any gestures that were completed and is now being reverted. if (root.stoppingGestures !== null) { stopCompletedGestures(root); @@ -3331,7 +3331,7 @@ function commitRoot( const concurrentlyUpdatedLanes = getConcurrentlyUpdatedLanes(); remainingLanes = mergeLanes(remainingLanes, concurrentlyUpdatedLanes); - if (enableSwipeTransition && root.pendingGestures === null) { + if (enableGestureTransition && root.pendingGestures === null) { // Gestures don't clear their lanes while the gesture is still active but it // might not be scheduled to do any more renders and so we shouldn't schedule // any more gesture lane work until a new gesture is scheduled. @@ -3379,7 +3379,7 @@ function commitRoot( pendingSuspendedCommitReason = suspendedCommitReason; } - if (enableSwipeTransition && isGestureRender(lanes)) { + if (enableGestureTransition && isGestureRender(lanes)) { // This is a special kind of render that doesn't commit regular effects. commitGestureOnRoot( root, @@ -3505,7 +3505,7 @@ function commitRoot( } let willStartViewTransition = shouldStartViewTransition; - if (enableSwipeTransition) { + if (enableGestureTransition) { // Stop any gestures that were completed and is now being committed. if (root.stoppingGestures !== null) { stopCompletedGestures(root); @@ -3944,7 +3944,7 @@ function commitGestureOnRoot( } function flushGestureMutations(): void { - if (!enableSwipeTransition) { + if (!enableGestureTransition) { return; } if (pendingEffectsStatus !== PENDING_GESTURE_MUTATION_PHASE) { @@ -3973,7 +3973,7 @@ function flushGestureMutations(): void { } function flushGestureAnimations(): void { - if (!enableSwipeTransition) { + if (!enableGestureTransition) { return; } // If we get canceled before we start we might not have applied diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index a683401283e8c..9e5689383557f 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -17,7 +17,6 @@ import type { Awaited, ReactComponentInfo, ReactDebugInfo, - StartGesture, } from 'shared/ReactTypes'; import type {WorkTag} from './ReactWorkTags'; import type {TypeOfMode} from './ReactTypeOfMode'; @@ -61,8 +60,7 @@ export type HookType = | 'useCacheRefresh' | 'useOptimistic' | 'useFormState' - | 'useActionState' - | 'useSwipeTransition'; + | 'useActionState'; export type ContextDependency = { context: ReactContext, @@ -282,7 +280,7 @@ type BaseFiberRootProperties = { formState: ReactFormState | null, - // enableSwipeTransition only + // enableGestureTransition only pendingGestures: null | ScheduledGesture, stoppingGestures: null | ScheduledGesture, gestureClone: null | Instance, @@ -446,12 +444,6 @@ export type Dispatcher = { initialState: Awaited, permalink?: string, ) => [Awaited, (P) => void, boolean], - // TODO: Non-nullable once `enableSwipeTransition` is on everywhere. - useSwipeTransition?: ( - previous: T, - current: T, - next: T, - ) => [T, StartGesture], }; export type AsyncDispatcher = { diff --git a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js index b4a025678b0de..050b1650c3b69 100644 --- a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js +++ b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js @@ -157,8 +157,6 @@ export const startViewTransition = $$$config.startViewTransition; export const startGestureTransition = $$$config.startGestureTransition; export const stopViewTransition = $$$config.stopViewTransition; export const getCurrentGestureOffset = $$$config.getCurrentGestureOffset; -export const subscribeToGestureDirection = - $$$config.subscribeToGestureDirection; export const createViewTransitionInstance = $$$config.createViewTransitionInstance; export const clearContainer = $$$config.clearContainer; diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 8ae00568ae670..4ad33f9cea3f0 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -16,7 +16,6 @@ import type { Usable, ReactCustomFormAction, Awaited, - StartGesture, } from 'shared/ReactTypes'; import type {ResumableState} from './ReactFizzConfig'; @@ -39,10 +38,7 @@ import { } from './ReactFizzConfig'; import {createFastHash} from './ReactServerStreamConfig'; -import { - enableUseEffectEventHook, - enableSwipeTransition, -} from 'shared/ReactFeatureFlags'; +import {enableUseEffectEventHook} from 'shared/ReactFeatureFlags'; import is from 'shared/objectIs'; import { REACT_CONTEXT_TYPE, @@ -799,19 +795,6 @@ function useMemoCache(size: number): Array { return data; } -function unsupportedStartGesture() { - throw new Error('startGesture cannot be called during server rendering.'); -} - -function useSwipeTransition( - previous: T, - current: T, - next: T, -): [T, StartGesture] { - resolveCurrentlyRenderingComponent(); - return [current, unsupportedStartGesture]; -} - function noop(): void {} function clientHookNotSupported() { @@ -880,11 +863,6 @@ export const HooksDispatcher: Dispatcher = supportsClientAPIs if (enableUseEffectEventHook) { HooksDispatcher.useEffectEvent = useEffectEvent; } -if (enableSwipeTransition) { - HooksDispatcher.useSwipeTransition = supportsClientAPIs - ? useSwipeTransition - : clientHookNotSupported; -} export let currentResumableState: null | ResumableState = (null: any); export function setCurrentResumableState( diff --git a/packages/react-server/src/ReactFlightHooks.js b/packages/react-server/src/ReactFlightHooks.js index f1d31f3e486eb..bcf36d4c9b7fd 100644 --- a/packages/react-server/src/ReactFlightHooks.js +++ b/packages/react-server/src/ReactFlightHooks.js @@ -17,10 +17,7 @@ import { } from 'shared/ReactSymbols'; import {createThenableState, trackUsedThenable} from './ReactFlightThenable'; import {isClientReference} from './ReactFlightServerConfig'; -import { - enableUseEffectEventHook, - enableSwipeTransition, -} from 'shared/ReactFeatureFlags'; +import {enableUseEffectEventHook} from 'shared/ReactFeatureFlags'; let currentRequest = null; let thenableIndexCounter = 0; @@ -102,9 +99,6 @@ export const HooksDispatcher: Dispatcher = { if (enableUseEffectEventHook) { HooksDispatcher.useEffectEvent = (unsupportedHook: any); } -if (enableSwipeTransition) { - HooksDispatcher.useSwipeTransition = (unsupportedHook: any); -} function unsupportedHook(): void { throw new Error('This Hook is not supported in Server Components.'); diff --git a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js index f3701d3063b75..9145d8e7e487a 100644 --- a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js +++ b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js @@ -501,14 +501,6 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number { return 0; } -export function subscribeToGestureDirection( - provider: GestureTimeline, - currentOffset: number, - directionCallback: (direction: boolean) => void, -): () => void { - return () => {}; -} - export function beforeActiveInstanceBlur(internalInstanceHandle: Object) { // noop } diff --git a/packages/react/index.experimental.development.js b/packages/react/index.experimental.development.js index e1613bf173889..cfa916dd67855 100644 --- a/packages/react/index.experimental.development.js +++ b/packages/react/index.experimental.development.js @@ -34,7 +34,6 @@ export { unstable_SuspenseList, unstable_ViewTransition, unstable_startGestureTransition, - unstable_useSwipeTransition, unstable_addTransitionType, unstable_useCacheRefresh, useId, diff --git a/packages/react/index.experimental.js b/packages/react/index.experimental.js index 02fb4a296f2ba..628746716e347 100644 --- a/packages/react/index.experimental.js +++ b/packages/react/index.experimental.js @@ -34,7 +34,6 @@ export { unstable_SuspenseList, unstable_ViewTransition, unstable_startGestureTransition, - unstable_useSwipeTransition, unstable_addTransitionType, unstable_useCacheRefresh, useId, diff --git a/packages/react/src/ReactClient.js b/packages/react/src/ReactClient.js index 0ae2177d9b170..3ead64acf682f 100644 --- a/packages/react/src/ReactClient.js +++ b/packages/react/src/ReactClient.js @@ -57,7 +57,6 @@ import { use, useOptimistic, useActionState, - useSwipeTransition, } from './ReactHooks'; import ReactSharedInternals from './ReactSharedInternalsClient'; import {startTransition, startGestureTransition} from './ReactStartTransition'; @@ -127,9 +126,8 @@ export { // enableViewTransition REACT_VIEW_TRANSITION_TYPE as unstable_ViewTransition, addTransitionType as unstable_addTransitionType, - // enableSwipeTransition + // enableGestureTransition startGestureTransition as unstable_startGestureTransition, - useSwipeTransition as unstable_useSwipeTransition, // DEV-only useId, act, diff --git a/packages/react/src/ReactHooks.js b/packages/react/src/ReactHooks.js index 7b0ef0b5aabba..ff86130baa050 100644 --- a/packages/react/src/ReactHooks.js +++ b/packages/react/src/ReactHooks.js @@ -13,14 +13,11 @@ import type { StartTransitionOptions, Usable, Awaited, - StartGesture, } from 'shared/ReactTypes'; import {REACT_CONSUMER_TYPE} from 'shared/ReactSymbols'; import ReactSharedInternals from 'shared/ReactSharedInternals'; -import {enableSwipeTransition} from 'shared/ReactFeatureFlags'; - type BasicStateAction = (S => S) | S; type Dispatch = A => void; @@ -242,16 +239,3 @@ export function useActionState( const dispatcher = resolveDispatcher(); return dispatcher.useActionState(action, initialState, permalink); } - -export function useSwipeTransition( - previous: T, - current: T, - next: T, -): [T, StartGesture] { - if (!enableSwipeTransition) { - throw new Error('Not implemented.'); - } - const dispatcher = resolveDispatcher(); - // $FlowFixMe[not-a-function] This is unstable, thus optional - return dispatcher.useSwipeTransition(previous, current, next); -} diff --git a/packages/react/src/ReactSharedInternalsClient.js b/packages/react/src/ReactSharedInternalsClient.js index 6d4abe88304d9..8fba0750ae9d9 100644 --- a/packages/react/src/ReactSharedInternalsClient.js +++ b/packages/react/src/ReactSharedInternalsClient.js @@ -15,7 +15,7 @@ import type {GestureProvider, GestureOptions} from 'shared/ReactTypes'; import { enableViewTransition, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; export type SharedStateClient = { @@ -58,7 +58,7 @@ const ReactSharedInternals: SharedStateClient = ({ T: null, S: null, }: any); -if (enableSwipeTransition) { +if (enableGestureTransition) { ReactSharedInternals.G = null; } if (enableViewTransition) { diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js index 9047d0adda0a7..249e4ca6d0dfd 100644 --- a/packages/react/src/ReactStartTransition.js +++ b/packages/react/src/ReactStartTransition.js @@ -18,13 +18,13 @@ import ReactSharedInternals from 'shared/ReactSharedInternals'; import { enableTransitionTracing, - enableSwipeTransition, + enableGestureTransition, } from 'shared/ReactFeatureFlags'; import reportGlobalError from 'shared/reportGlobalError'; export type Transition = { - gesture: null | GestureProvider, // enableSwipeTransition + gesture: null | GestureProvider, // enableGestureTransition name: null | string, // enableTransitionTracing only startTime: number, // enableTransitionTracing only _updatedFibers: Set, // DEV-only @@ -37,7 +37,7 @@ export function startTransition( ): void { const prevTransition = ReactSharedInternals.T; const currentTransition: Transition = ({}: any); - if (enableSwipeTransition) { + if (enableGestureTransition) { currentTransition.gesture = null; } if (enableTransitionTracing) { @@ -76,10 +76,10 @@ export function startGestureTransition( scope: () => void, options?: GestureOptions & StartTransitionOptions, ): () => void { - if (!enableSwipeTransition) { + if (!enableGestureTransition) { // eslint-disable-next-line react-internal/prod-error-codes throw new Error( - 'startGestureTransition should not be exported when the enableSwipeTransition flag is off.', + 'startGestureTransition should not be exported when the enableGestureTransition flag is off.', ); } if (provider == null) { @@ -92,7 +92,7 @@ export function startGestureTransition( } const prevTransition = ReactSharedInternals.T; const currentTransition: Transition = ({}: any); - if (enableSwipeTransition) { + if (enableGestureTransition) { currentTransition.gesture = provider; } if (enableTransitionTracing) { diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 9831ad05afd7d..106460b7c08fd 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -92,7 +92,7 @@ export const enableHalt = __EXPERIMENTAL__; export const enableViewTransition = __EXPERIMENTAL__; -export const enableSwipeTransition = __EXPERIMENTAL__; +export const enableGestureTransition = __EXPERIMENTAL__; export const enableScrollEndPolyfill = __EXPERIMENTAL__; diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js index fbbd62f3af547..95515143a4fc1 100644 --- a/packages/shared/ReactTypes.js +++ b/packages/shared/ReactTypes.js @@ -171,11 +171,6 @@ export type ReactFormState = [ // renderer supports it. export type GestureProvider = any; -export type StartGesture = ( - gestureProvider: GestureProvider, - gestureOptions: GestureOptions, -) => () => void; - export type GestureOptions = { direction?: 'previous' | 'next', range?: [/*previous*/ number, /*current*/ number, /*next*/ number], diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 70857c99e5b21..0f34a6364fa6e 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -80,7 +80,7 @@ export const enableHydrationLaneScheduling = true; export const enableYieldingBeforePassive = false; export const enableThrottledScheduling = false; export const enableViewTransition = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const enableScrollEndPolyfill = true; export const enableFragmentRefs = false; export const ownerStackLimit = 1e4; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index e6305e4952f37..33d97eca70405 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -70,7 +70,7 @@ export const enableYieldingBeforePassive = false; export const enableThrottledScheduling = false; export const enableViewTransition = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const enableFastAddPropertiesInDiffing = false; export const enableLazyPublicInstanceInFabric = false; export const enableScrollEndPolyfill = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 1c089f74cc2f3..0162b75a7ae87 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -69,7 +69,7 @@ export const enableYieldingBeforePassive = true; export const enableThrottledScheduling = false; export const enableViewTransition = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const enableFastAddPropertiesInDiffing = true; export const enableLazyPublicInstanceInFabric = false; export const enableScrollEndPolyfill = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js index 01b07a36b951d..3809542ddfd9c 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js @@ -66,7 +66,7 @@ export const enableHydrationLaneScheduling = true; export const enableYieldingBeforePassive = false; export const enableThrottledScheduling = false; export const enableViewTransition = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const enableFastAddPropertiesInDiffing = false; export const enableLazyPublicInstanceInFabric = false; export const enableScrollEndPolyfill = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 9cd2d5369cdee..422c6ce471693 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -80,7 +80,7 @@ export const enableYieldingBeforePassive = false; export const enableThrottledScheduling = false; export const enableViewTransition = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const enableFastAddPropertiesInDiffing = false; export const enableLazyPublicInstanceInFabric = false; export const enableScrollEndPolyfill = true; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 64a5ff4126b6f..23ac44b37c6a6 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -111,7 +111,7 @@ export const enableShallowPropDiffing = false; export const enableLazyPublicInstanceInFabric = false; -export const enableSwipeTransition = false; +export const enableGestureTransition = false; export const ownerStackLimit = 1e4; diff --git a/scripts/error-codes/codes.json b/scripts/error-codes/codes.json index 46bf894eff540..12eac760d9b38 100644 --- a/scripts/error-codes/codes.json +++ b/scripts/error-codes/codes.json @@ -535,9 +535,9 @@ "547": "startGesture cannot be called during server rendering.", "548": "Finished rendering the gesture lane but there were no pending gestures. React should not have started a render in this case. This is a bug in React.", "549": "Cannot start a gesture with a disconnected AnimationTimeline.", - "550": "useSwipeTransition is not yet supported in react-art.", - "551": "useSwipeTransition is not yet supported in React Native.", - "552": "Cannot use a useSwipeTransition() in a detached root.", + "550": "startGestureTransition is not yet supported in react-art.", + "551": "startGestureTransition is not yet supported in React Native.", + "552": "Cannot use a startGestureTransition() on a detached root.", "553": "A Timeline is required as the first argument to startGestureTransition.", "554": "Cannot setState on regular state inside a startGestureTransition. Gestures can only update the useOptimistic() hook. There should be no side-effects associated with starting a Gesture until its Action is invoked. Move side-effects to the Action instead.", "555": "Cannot requestFormReset() inside a startGestureTransition. There should be no side-effects associated with starting a Gesture until its Action is invoked. Move side-effects to the Action instead."