@samitouri / QOS-React-1 / commits / 0a7cf20b22

Remove useSwipeTransition (#32786)

Stacked on #32785. This is now replaced by `startGestureTransition` added in #32785. I also renamed the flag from `enableSwipeTransition` to `enableGestureTransition` to correspond to the new name.

Sebastian Markbåge committed Apr 1, 2025 at 11:43 UTC 0a7cf20b220a9f719e06fd8a12dfde3ab029c651
34 files changed +66 -618
packages/react-art/src/ReactFiberConfigART.js
+1 -9
@@ -560,15 +560,7 @@ export function createViewTransitionInstance(
560 export type GestureTimeline = null;
561
562 export function getCurrentGestureOffset(provider: GestureTimeline): number {
563 - throw new Error('useSwipeTransition is not yet supported in react-art.');
564 -}
565 -
566 -export function subscribeToGestureDirection(
567 - provider: GestureTimeline,
568 - currentOffset: number,
569 - directionCallback: (direction: boolean) => void,
570 -): () => void {
571 - throw new Error('useSwipeTransition is not yet supported in react-art.');
563 + throw new Error('startGestureTransition is not yet supported in react-art.');
564 }
565
566 export function clearContainer(container) {
packages/react-debug-tools/src/ReactDebugHooks.js
-22
@@ -14,7 +14,6 @@ import type {
14 Usable,
15 Thenable,
16 ReactDebugInfo,
17 - StartGesture,
17 } from 'shared/ReactTypes';
18 import type {
19 ContextDependency,
@@ -132,9 +131,6 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
131 if (typeof Dispatcher.useEffectEvent === 'function') {
132 Dispatcher.useEffectEvent((args: empty) => {});
133 }
135 - if (typeof Dispatcher.useSwipeTransition === 'function') {
136 - Dispatcher.useSwipeTransition(null, null, null);
137 - }
134 } finally {
135 readHookLog = hookLog;
136 hookLog = [];
@@ -753,23 +749,6 @@ function useEffectEvent<Args, F: (...Array<Args>) => mixed>(callback: F): F {
749 return callback;
750 }
751
756 -function useSwipeTransition<T>(
757 - previous: T,
758 - current: T,
759 - next: T,
760 -): [T, StartGesture] {
761 - nextHook();
762 - hookLog.push({
763 - displayName: null,
764 - primitive: 'SwipeTransition',
765 - stackError: new Error(),
766 - value: current,
767 - debugInfo: null,
768 - dispatcherHookName: 'SwipeTransition',
769 - });
770 - return [current, () => () => {}];
771 -}
772 -
752 const Dispatcher: DispatcherType = {
753 readContext,
754
@@ -796,7 +775,6 @@ const Dispatcher: DispatcherType = {
775 useMemoCache,
776 useCacheRefresh,
777 useEffectEvent,
799 - useSwipeTransition,
778 };
779
780 // create a proxy to throw a custom error
packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+6 -46
@@ -1358,7 +1358,9 @@ export function cloneRootViewTransitionContainer(
1358
1359 const containerParent = containerInstance.parentNode;
1360 if (containerParent === null) {
1361 - throw new Error('Cannot use a useSwipeTransition() in a detached root.');
1361 + throw new Error(
1362 + 'Cannot use a startGestureTransition() on a detached root.',
1363 + );
1364 }
1365
1366 const clone: HTMLElement = containerInstance.cloneNode(false);
@@ -1464,7 +1466,9 @@ export function removeRootViewTransitionClone(
1466 }
1467 const containerParent = containerInstance.parentNode;
1468 if (containerParent === null) {
1467 - throw new Error('Cannot use a useSwipeTransition() in a detached root.');
1469 + throw new Error(
1470 + 'Cannot use a startGestureTransition() on a detached root.',
1471 + );
1472 }
1473 // We assume that the clone is still within the same parent.
1474 containerParent.removeChild(clone);
@@ -2172,50 +2176,6 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number {
2176 return typeof time === 'number' ? time : time.value;
2177 }
2178
2175 -export function subscribeToGestureDirection(
2176 - provider: GestureTimeline,
2177 - currentOffset: number,
2178 - directionCallback: (direction: boolean) => void,
2179 -): () => void {
2180 - if (
2181 - typeof ScrollTimeline === 'function' &&
2182 - provider instanceof ScrollTimeline
2183 - ) {
2184 - // For ScrollTimeline we optimize to only update the current time on scroll events.
2185 - const element = provider.source;
2186 - const scrollCallback = () => {
2187 - const newTime = provider.currentTime;
2188 - if (newTime !== null) {
2189 - const newValue = typeof newTime === 'number' ? newTime : newTime.value;
2190 - if (newValue !== currentOffset) {
2191 - directionCallback(newValue > currentOffset);
2192 - }
2193 - }
2194 - };
2195 - element.addEventListener('scroll', scrollCallback, false);
2196 - return () => {
2197 - element.removeEventListener('scroll', scrollCallback, false);
2198 - };
2199 - } else {
2200 - // For other AnimationTimelines, such as DocumentTimeline, we just update every rAF.
2201 - // TODO: Optimize ViewTimeline using an IntersectionObserver if it becomes common.
2202 - const rafCallback = () => {
2203 - const newTime = provider.currentTime;
2204 - if (newTime !== null) {
2205 - const newValue = typeof newTime === 'number' ? newTime : newTime.value;
2206 - if (newValue !== currentOffset) {
2207 - directionCallback(newValue > currentOffset);
2208 - }
2209 - }
2210 - callbackID = requestAnimationFrame(rafCallback);
2211 - };
2212 - let callbackID = requestAnimationFrame(rafCallback);
2213 - return () => {
2214 - cancelAnimationFrame(callbackID);
2215 - };
2216 - }
2217 -}
2218 -
2179 type EventListenerOptionsOrUseCapture =
2180 | boolean
2181 | {
packages/react-native-renderer/src/ReactFiberConfigNative.js
+3 -9
@@ -692,15 +692,9 @@ export function createViewTransitionInstance(
692 export type GestureTimeline = null;
693
694 export function getCurrentGestureOffset(provider: GestureTimeline): number {
695 - throw new Error('useSwipeTransition is not yet supported in React Native.');
696 -}
697 -
698 -export function subscribeToGestureDirection(
699 - provider: GestureTimeline,
700 - currentOffset: number,
701 - directionCallback: (direction: boolean) => void,
702 -): () => void {
703 - throw new Error('useSwipeTransition is not yet supported in React Native.');
695 + throw new Error(
696 + 'startGestureTransition is not yet supported in React Native.',
697 + );
698 }
699
700 export function clearContainer(container: Container): void {
packages/react-noop-renderer/src/createReactNoop.js
-8
@@ -865,14 +865,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
865 return 0;
866 },
867
868 - subscribeToGestureDirection(
869 - provider: GestureTimeline,
870 - currentOffset: number,
871 - directionCallback: (direction: boolean) => void,
872 - ): () => void {
873 - return () => {};
874 - },
875 -
868 resetTextContent(instance: Instance): void {
869 instance.text = null;
870 },
packages/react-reconciler/src/ReactFiberApplyGesture.js
+4 -4
@@ -412,7 +412,7 @@ function recursivelyInsertNewFiber(
412 // had any effect.
413 if (finishedWork.flags & Update) {
414 console.error(
415 - 'useSwipeTransition() caused something to render a new <%s>. ' +
415 + 'startGestureTransition() caused something to render a new <%s>. ' +
416 'This is not possible in the current implementation. ' +
417 "Make sure that the swipe doesn't mount any new <%s> elements.",
418 finishedWork.type,
@@ -789,7 +789,7 @@ function insertDestinationClonesOfFiber(
789 commitUpdate(instance, type, oldProps, newProps, finishedWork);
790 if (viewTransitionMutationContext) {
791 console.error(
792 - 'useSwipeTransition() caused something to mutate <%s>. ' +
792 + 'startGestureTransition() caused something to mutate <%s>. ' +
793 'This is not possible in the current implementation. ' +
794 "Make sure that the swipe doesn't update any state which " +
795 'causes <%s> to change.',
@@ -977,10 +977,10 @@ export function insertDestinationClones(
977 if (!didWarnForRootClone) {
978 didWarnForRootClone = true;
979 console.warn(
980 - 'useSwipeTransition() caused something to mutate or relayout the root. ' +
980 + 'startGestureTransition() caused something to mutate or relayout the root. ' +
981 'This currently requires a clone of the whole document. Make sure to ' +
982 'add a <ViewTransition> directly around an absolutely positioned DOM node ' +
983 - 'to minimize the impact of any changes caused by the Swipe Transition.',
983 + 'to minimize the impact of any changes caused by the Gesture Transition.',
984 );
985 }
986 }
packages/react-reconciler/src/ReactFiberConcurrentUpdates.js
+1 -27
@@ -24,14 +24,7 @@ import {
24 throwIfInfiniteUpdateLoopDetected,
25 getWorkInProgressRoot,
26 } from './ReactFiberWorkLoop';
27 -import {
28 - NoLane,
29 - NoLanes,
30 - mergeLanes,
31 - markHiddenUpdate,
32 - markRootUpdated,
33 - GestureLane,
34 -} from './ReactFiberLane';
27 +import {NoLane, NoLanes, mergeLanes, markHiddenUpdate} from './ReactFiberLane';
28 import {NoFlags, Placement, Hydrating} from './ReactFiberFlags';
29 import {HostRoot, OffscreenComponent} from './ReactWorkTags';
30 import {OffscreenVisible} from './ReactFiberActivityComponent';
@@ -176,25 +169,6 @@ export function enqueueConcurrentRenderForLane(
169 return getRootForUpdatedFiber(fiber);
170 }
171
179 -export function enqueueGestureRender(fiber: Fiber): FiberRoot | null {
180 - // We can't use the concurrent queuing for these so this is basically just a
181 - // short cut for marking the lane on the parent path. It is possible for a
182 - // gesture render to suspend and then in the gap get another gesture starting.
183 - // However, marking the lane doesn't make much different in this case because
184 - // it would have to call startGesture with the same exact provider as was
185 - // already rendering. Because otherwise it has no effect on the Hook itself.
186 - // TODO: We could potentially solve this case by popping a ScheduledGesture
187 - // off the root's queue while we're rendering it so that it can't dedupe
188 - // and so new startGesture with the same provider would create a new
189 - // ScheduledGesture which goes into a separate render pass anyway.
190 - // This is such an edge case it probably doesn't matter much.
191 - const root = markUpdateLaneFromFiberToRoot(fiber, null, GestureLane);
192 - if (root !== null) {
193 - markRootUpdated(root, GestureLane);
194 - }
195 - return root;
196 -}
197 -
172 // Calling this function outside this module should only be done for backwards
173 // compatibility and should always be accompanied by a warning.
174 export function unsafe_markUpdateLaneFromFiberToRoot(
packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js
-1
@@ -58,4 +58,3 @@ export type ViewTransitionInstance = null | {name: string, ...};
58 export const createViewTransitionInstance = shim;
59 export type GestureTimeline = any;
60 export const getCurrentGestureOffset = shim;
61 -export const subscribeToGestureDirection = shim;
packages/react-reconciler/src/ReactFiberGestureScheduler.js
+1 -82
@@ -17,11 +17,7 @@ import {
17 includesTransitionLane,
18 } from './ReactFiberLane';
19 import {ensureRootIsScheduled} from './ReactFiberRootScheduler';
20 -import {
21 - subscribeToGestureDirection,
22 - getCurrentGestureOffset,
23 - stopViewTransition,
24 -} from './ReactFiberConfig';
20 +import {getCurrentGestureOffset, stopViewTransition} from './ReactFiberConfig';
21
22 // This type keeps track of any scheduled or active gestures.
23 export type ScheduledGesture = {
@@ -31,85 +27,11 @@ export type ScheduledGesture = {
27 rangePrevious: number, // The end along the timeline where the previous state is reached.
28 rangeCurrent: number, // The starting offset along the timeline.
29 rangeNext: number, // The end along the timeline where the next state is reached.
34 - cancel: () => void, // Cancel the subscription to direction change. // TODO: Delete this.
30 running: null | RunningViewTransition, // Used to cancel the running transition after we're done.
31 prev: null | ScheduledGesture, // The previous scheduled gesture in the queue for this root.
32 next: null | ScheduledGesture, // The next scheduled gesture in the queue for this root.
33 };
34
40 -// TODO: Delete this when deleting useSwipeTransition.
41 -export function scheduleGestureLegacy(
42 - root: FiberRoot,
43 - provider: GestureTimeline,
44 - initialDirection: boolean,
45 - rangePrevious: number,
46 - rangeCurrent: number,
47 - rangeNext: number,
48 -): ScheduledGesture {
49 - let prev = root.pendingGestures;
50 - while (prev !== null) {
51 - if (prev.provider === provider) {
52 - // Existing instance found.
53 - prev.count++;
54 - return prev;
55 - }
56 - const next = prev.next;
57 - if (next === null) {
58 - break;
59 - }
60 - prev = next;
61 - }
62 - const isFlippedDirection = rangePrevious > rangeNext;
63 - // Add new instance to the end of the queue.
64 - const cancel = subscribeToGestureDirection(
65 - provider,
66 - rangeCurrent,
67 - (direction: boolean) => {
68 - if (isFlippedDirection) {
69 - direction = !direction;
70 - }
71 - if (gesture.direction !== direction) {
72 - gesture.direction = direction;
73 - if (gesture.prev === null && root.pendingGestures !== gesture) {
74 - // This gesture is not in the schedule, meaning it was already rendered.
75 - // We need to rerender in the new direction. Insert it into the first slot
76 - // in case other gestures are queued after the on-going one.
77 - const existing = root.pendingGestures;
78 - gesture.next = existing;
79 - if (existing !== null) {
80 - existing.prev = gesture;
81 - }
82 - root.pendingGestures = gesture;
83 - // Schedule the lane on the root. The Fibers will already be marked as
84 - // long as the gesture is active on that Hook.
85 - root.pendingLanes |= GestureLane;
86 - ensureRootIsScheduled(root);
87 - }
88 - // TODO: If we're currently rendering this gesture, we need to restart it.
89 - }
90 - },
91 - );
92 - const gesture: ScheduledGesture = {
93 - provider: provider,
94 - count: 1,
95 - direction: initialDirection,
96 - rangePrevious: rangePrevious,
97 - rangeCurrent: rangeCurrent,
98 - rangeNext: rangeNext,
99 - cancel: cancel,
100 - running: null,
101 - prev: prev,
102 - next: null,
103 - };
104 - if (prev === null) {
105 - root.pendingGestures = gesture;
106 - } else {
107 - prev.next = gesture;
108 - }
109 - ensureRootIsScheduled(root);
110 - return gesture;
111 -}
112 -
35 export function scheduleGesture(
36 root: FiberRoot,
37 provider: GestureTimeline,
@@ -133,7 +55,6 @@ export function scheduleGesture(
55 rangePrevious: -1,
56 rangeCurrent: -1,
57 rangeNext: -1,
136 - cancel: () => {}, // TODO: Delete this with useSwipeTransition.
58 running: null,
59 prev: prev,
60 next: null,
@@ -210,8 +131,6 @@ export function cancelScheduledGesture(
131 ): void {
132 gesture.count--;
133 if (gesture.count === 0) {
213 - const cancelDirectionSubscription = gesture.cancel;
214 - cancelDirectionSubscription();
134 // Delete the scheduled gesture from the pending queue.
135 deleteScheduledGesture(root, gesture);
136 // TODO: If we're currently rendering this gesture, we need to restart the render
packages/react-reconciler/src/ReactFiberHooks.js
+10 -299
@@ -14,9 +14,6 @@ import type {
14 Thenable,
15 RejectedThenable,
16 Awaited,
17 - StartGesture,
18 - GestureProvider,
19 - GestureOptions,
17 } from 'shared/ReactTypes';
18 import type {
19 Fiber,
@@ -28,7 +25,7 @@ import type {
25 import type {Lanes, Lane} from './ReactFiberLane';
26 import type {HookFlags} from './ReactHookEffectTags';
27 import type {Flags} from './ReactFiberFlags';
31 -import type {TransitionStatus, GestureTimeline} from './ReactFiberConfig';
28 +import type {TransitionStatus} from './ReactFiberConfig';
29 import type {ScheduledGesture} from './ReactFiberGestureScheduler';
30
31 import {
@@ -36,7 +33,6 @@ import {
33 NotPendingTransition as NoPendingHostTransition,
34 setCurrentUpdatePriority,
35 getCurrentUpdatePriority,
39 - getCurrentGestureOffset,
36 } from './ReactFiberConfig';
37 import ReactSharedInternals from 'shared/ReactSharedInternals';
38 import {
@@ -46,7 +42,7 @@ import {
42 enableLegacyCache,
43 disableLegacyMode,
44 enableNoCloningMemoCache,
49 - enableSwipeTransition,
45 + enableGestureTransition,
46 } from 'shared/ReactFeatureFlags';
47 import {
48 REACT_CONTEXT_TYPE,
@@ -137,7 +133,6 @@ import {
133 enqueueConcurrentHookUpdate,
134 enqueueConcurrentHookUpdateAndEagerlyBailout,
135 enqueueConcurrentRenderForLane,
140 - enqueueGestureRender,
136 } from './ReactFiberConcurrentUpdates';
137 import {getTreeId} from './ReactFiberTreeContext';
138 import {now} from './Scheduler';
@@ -161,11 +156,7 @@ import {requestCurrentTransition} from './ReactFiberTransition';
156
157 import {callComponentInDEV} from './ReactFiberCallUserSpace';
158
164 -import {
165 - scheduleGesture,
166 - scheduleGestureLegacy,
167 - cancelScheduledGesture,
168 -} from './ReactFiberGestureScheduler';
159 +import {scheduleGesture} from './ReactFiberGestureScheduler';
160
161 export type Update<S, A> = {
162 lane: Lane,
@@ -174,7 +165,7 @@ export type Update<S, A> = {
165 hasEagerState: boolean,
166 eagerState: S | null,
167 next: Update<S, A>,
177 - gesture: null | ScheduledGesture, // enableSwipeTransition
168 + gesture: null | ScheduledGesture, // enableGestureTransition
169 };
170
171 export type UpdateQueue<S, A> = {
@@ -1383,7 +1374,7 @@ function updateReducerImpl<S, A>(
1374 ? !isSubsetOfLanes(getWorkInProgressRootRenderLanes(), updateLane)
1375 : !isSubsetOfLanes(renderLanes, updateLane);
1376
1386 - if (enableSwipeTransition && updateLane === GestureLane) {
1377 + if (enableGestureTransition && updateLane === GestureLane) {
1378 // This is a gesture optimistic update. It should only be considered as part of the
1379 // rendered state while rendering the gesture lane and if the rendering the associated
1380 // ScheduledGesture.
@@ -2168,7 +2159,7 @@ function runActionStateAction<S, P>(
2159 // This is a fork of startTransition
2160 const prevTransition = ReactSharedInternals.T;
2161 const currentTransition: Transition = ({}: any);
2171 - if (enableSwipeTransition) {
2162 + if (enableGestureTransition) {
2163 currentTransition.gesture = null;
2164 }
2165 if (enableTransitionTracing) {
@@ -3050,7 +3041,7 @@ function startTransition<S>(
3041
3042 const prevTransition = ReactSharedInternals.T;
3043 const currentTransition: Transition = ({}: any);
3053 - if (enableSwipeTransition) {
3044 + if (enableGestureTransition) {
3045 currentTransition.gesture = null;
3046 }
3047 if (enableTransitionTracing) {
@@ -3278,7 +3269,7 @@ export function requestFormReset(formFiber: Fiber) {
3269 'fix, move to an action, or wrap with startTransition.',
3270 );
3271 }
3281 - } else if (enableSwipeTransition && transition.gesture) {
3272 + } else if (enableGestureTransition && transition.gesture) {
3273 throw new Error(
3274 'Cannot requestFormReset() inside a startGestureTransition. ' +
3275 'There should be no side-effects associated with starting a ' +
@@ -3655,7 +3646,7 @@ function dispatchOptimisticSetState<S, A>(
3646 // For regular Transitions an optimistic update commits synchronously.
3647 // For gesture Transitions an optimistic update commits on the GestureLane.
3648 const lane =
3658 - enableSwipeTransition && transition !== null && transition.gesture
3649 + enableGestureTransition && transition !== null && transition.gesture
3650 ? GestureLane
3651 : SyncLane;
3652 const update: Update<S, A> = {
@@ -3696,7 +3687,7 @@ function dispatchOptimisticSetState<S, A>(
3687 scheduleUpdateOnFiber(root, fiber, lane);
3688 // Optimistic updates are always synchronous, so we don't need to call
3689 // entangleTransitionUpdate here.
3699 - if (enableSwipeTransition && transition !== null) {
3690 + if (enableGestureTransition && transition !== null) {
3691 const provider = transition.gesture;
3692 if (provider !== null) {
3693 // If this was a gesture, ensure we have a scheduled gesture and that
@@ -3770,183 +3761,6 @@ function markUpdateInDevTools<A>(fiber: Fiber, lane: Lane, action: A): void {
3761 }
3762 }
3763
3773 -type SwipeTransitionGestureUpdate = {
3774 - gesture: ScheduledGesture,
3775 - prev: SwipeTransitionGestureUpdate | null,
3776 - next: SwipeTransitionGestureUpdate | null,
3777 -};
3778 -
3779 -type SwipeTransitionUpdateQueue = {
3780 - pending: null | SwipeTransitionGestureUpdate,
3781 - dispatch: StartGesture,
3782 - initialDirection: boolean,
3783 -};
3784 -
3785 -function startGesture(
3786 - fiber: Fiber,
3787 - queue: SwipeTransitionUpdateQueue,
3788 - gestureProvider: GestureProvider,
3789 - gestureOptions?: GestureOptions,
3790 -): () => void {
3791 - const root = enqueueGestureRender(fiber);
3792 - if (root === null) {
3793 - // Already unmounted.
3794 - // TODO: Should we warn here about starting on an unmounted Fiber?
3795 - return function cancelGesture() {
3796 - // Noop.
3797 - };
3798 - }
3799 - const gestureTimeline: GestureTimeline = gestureProvider;
3800 - const currentOffset = getCurrentGestureOffset(gestureTimeline);
3801 - const range = gestureOptions && gestureOptions.range;
3802 - const rangePrevious: number = range ? range[0] : 0; // If no range is provider we assume it's the starting point of the range.
3803 - const rangeCurrent: number = range ? range[1] : currentOffset;
3804 - const rangeNext: number = range ? range[2] : 100; // If no range is provider we assume it's the starting point of the range.
3805 - if (__DEV__) {
3806 - if (
3807 - (rangePrevious > rangeCurrent && rangeNext > rangeCurrent) ||
3808 - (rangePrevious < rangeCurrent && rangeNext < rangeCurrent)
3809 - ) {
3810 - console.error(
3811 - 'The range of a gesture needs "previous" and "next" to be on either side of ' +
3812 - 'the "current" offset. Both cannot be above current and both cannot be below current.',
3813 - );
3814 - }
3815 - }
3816 - const isFlippedDirection = rangePrevious > rangeNext;
3817 - const initialDirection =
3818 - // If a range is specified we can imply initial direction if it's not the current
3819 - // value such as if the gesture starts after it has already moved.
3820 - currentOffset < rangeCurrent
3821 - ? isFlippedDirection
3822 - : currentOffset > rangeCurrent
3823 - ? !isFlippedDirection
3824 - : // Otherwise, look for an explicit option.
3825 - gestureOptions && gestureOptions.direction === 'next'
3826 - ? true
3827 - : gestureOptions && gestureOptions.direction === 'previous'
3828 - ? false
3829 - : // If no option is specified, imply from the values specified.
3830 - queue.initialDirection;
3831 - const scheduledGesture = scheduleGestureLegacy(
3832 - root,
3833 - gestureTimeline,
3834 - initialDirection,
3835 - rangePrevious,
3836 - rangeCurrent,
3837 - rangeNext,
3838 - );
3839 - // Add this particular instance to the queue.
3840 - // We add multiple of the same timeline even if they get batched so
3841 - // that if we cancel one but not the other we can keep track of this.
3842 - // Order doesn't matter but we insert in the beginning to avoid two fields.
3843 - const update: SwipeTransitionGestureUpdate = {
3844 - gesture: scheduledGesture,
3845 - prev: null,
3846 - next: queue.pending,
3847 - };
3848 - if (queue.pending !== null) {
3849 - queue.pending.prev = update;
3850 - }
3851 - queue.pending = update;
3852 - return function cancelGesture(): void {
3853 - if (update.prev === null) {
3854 - if (queue.pending === update) {
3855 - queue.pending = update.next;
3856 - } else {
3857 - // This was already cancelled. Avoid double decrementing if someone calls this twice by accident.
3858 - // TODO: Should we warn here about double cancelling?
3859 - return;
3860 - }
3861 - } else {
3862 - update.prev.next = update.next;
3863 - if (update.next !== null) {
3864 - update.next.prev = update.prev;
3865 - }
3866 - update.prev = null;
3867 - update.next = null;
3868 - }
3869 - const cancelledGestured = update.gesture;
3870 - // Decrement ref count of the root schedule.
3871 - cancelScheduledGesture(root, cancelledGestured);
3872 - };
3873 -}
3874 -
3875 -function mountSwipeTransition<T>(
3876 - previous: T,
3877 - current: T,
3878 - next: T,
3879 -): [T, StartGesture] {
3880 - const queue: SwipeTransitionUpdateQueue = {
3881 - pending: null,
3882 - dispatch: (null: any),
3883 - initialDirection: previous === current,
3884 - };
3885 - const startGestureOnHook: StartGesture = (queue.dispatch = (startGesture.bind(
3886 - null,
3887 - currentlyRenderingFiber,
3888 - queue,
3889 - ): any));
3890 - const hook = mountWorkInProgressHook();
3891 - hook.queue = queue;
3892 - return [current, startGestureOnHook];
3893 -}
3894 -
3895 -function updateSwipeTransition<T>(
3896 - previous: T,
3897 - current: T,
3898 - next: T,
3899 -): [T, StartGesture] {
3900 - const hook = updateWorkInProgressHook();
3901 - const queue: SwipeTransitionUpdateQueue = hook.queue;
3902 - const startGestureOnHook: StartGesture = queue.dispatch;
3903 - const rootRenderLanes = getWorkInProgressRootRenderLanes();
3904 - let value = current;
3905 - if (queue.pending !== null) {
3906 - if (isGestureRender(rootRenderLanes)) {
3907 - // We're inside a gesture render. We'll traverse the queue to see if
3908 - // this specific Hook is part of this gesture and, if so, which
3909 - // direction to render.
3910 - const root: FiberRoot | null = getWorkInProgressRoot();
3911 - if (root === null) {
3912 - throw new Error(
3913 - 'Expected a work-in-progress root. This is a bug in React. Please file an issue.',
3914 - );
3915 - }
3916 - // We assume that the currently rendering gesture is the one first in the queue.
3917 - const rootRenderGesture = root.pendingGestures;
3918 - if (rootRenderGesture !== null) {
3919 - let update = queue.pending;
3920 - while (update !== null) {
3921 - if (rootRenderGesture === update.gesture) {
3922 - // We had a match, meaning we're currently rendering a direction of this
3923 - // hook for this gesture.
3924 - value = rootRenderGesture.direction ? next : previous;
3925 - break;
3926 - }
3927 - update = update.next;
3928 - }
3929 - }
3930 - // This lane cannot be cleared as long as we have active gestures.
3931 - markWorkInProgressReceivedUpdate();
3932 - }
3933 - // As long as there are any active gestures we need to leave the lane on
3934 - // in case we need to render it later. Since a gesture render doesn't commit
3935 - // the only time it really fully gets cleared is if something else rerenders
3936 - // this component after all the active gestures has cleared.
3937 - currentlyRenderingFiber.lanes = mergeLanes(
3938 - currentlyRenderingFiber.lanes,
3939 - GestureLane,
3940 - );
3941 - }
3942 - // By default, we don't know which direction we should start until a movement
3943 - // has happened. However, if one direction has the same value as current we
3944 - // know that it's probably not that direction since it won't do anything anyway.
3945 - // TODO: Add an explicit option to provide this.
3946 - queue.initialDirection = previous === current;
3947 - return [value, startGestureOnHook];
3948 -}
3949 -
3764 export const ContextOnlyDispatcher: Dispatcher = {
3765 readContext,
3766
@@ -3976,10 +3790,6 @@ export const ContextOnlyDispatcher: Dispatcher = {
3790 if (enableUseEffectEventHook) {
3791 (ContextOnlyDispatcher: Dispatcher).useEffectEvent = throwInvalidHookError;
3792 }
3979 -if (enableSwipeTransition) {
3980 - (ContextOnlyDispatcher: Dispatcher).useSwipeTransition =
3981 - throwInvalidHookError;
3982 -}
3793
3794 const HooksDispatcherOnMount: Dispatcher = {
3795 readContext,
@@ -4010,10 +3820,6 @@ const HooksDispatcherOnMount: Dispatcher = {
3820 if (enableUseEffectEventHook) {
3821 (HooksDispatcherOnMount: Dispatcher).useEffectEvent = mountEvent;
3822 }
4013 -if (enableSwipeTransition) {
4014 - (HooksDispatcherOnMount: Dispatcher).useSwipeTransition =
4015 - mountSwipeTransition;
4016 -}
3823
3824 const HooksDispatcherOnUpdate: Dispatcher = {
3825 readContext,
@@ -4044,10 +3850,6 @@ const HooksDispatcherOnUpdate: Dispatcher = {
3850 if (enableUseEffectEventHook) {
3851 (HooksDispatcherOnUpdate: Dispatcher).useEffectEvent = updateEvent;
3852 }
4047 -if (enableSwipeTransition) {
4048 - (HooksDispatcherOnUpdate: Dispatcher).useSwipeTransition =
4049 - updateSwipeTransition;
4050 -}
3853
3854 const HooksDispatcherOnRerender: Dispatcher = {
3855 readContext,
@@ -4078,10 +3880,6 @@ const HooksDispatcherOnRerender: Dispatcher = {
3880 if (enableUseEffectEventHook) {
3881 (HooksDispatcherOnRerender: Dispatcher).useEffectEvent = updateEvent;
3882 }
4081 -if (enableSwipeTransition) {
4082 - (HooksDispatcherOnRerender: Dispatcher).useSwipeTransition =
4083 - updateSwipeTransition;
4084 -}
3883
3884 let HooksDispatcherOnMountInDEV: Dispatcher | null = null;
3885 let HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher | null = null;
@@ -4282,18 +4080,6 @@ if (__DEV__) {
4080 return mountEvent(callback);
4081 };
4082 }
4285 - if (enableSwipeTransition) {
4286 - (HooksDispatcherOnMountInDEV: Dispatcher).useSwipeTransition =
4287 - function useSwipeTransition<T>(
4288 - previous: T,
4289 - current: T,
4290 - next: T,
4291 - ): [T, StartGesture] {
4292 - currentHookNameInDev = 'useSwipeTransition';
4293 - mountHookTypesDev();
4294 - return mountSwipeTransition(previous, current, next);
4295 - };
4296 - }
4083
4084 HooksDispatcherOnMountWithHookTypesInDEV = {
4085 readContext<T>(context: ReactContext<T>): T {
@@ -4461,18 +4247,6 @@ if (__DEV__) {
4247 return mountEvent(callback);
4248 };
4249 }
4464 - if (enableSwipeTransition) {
4465 - (HooksDispatcherOnMountWithHookTypesInDEV: Dispatcher).useSwipeTransition =
4466 - function useSwipeTransition<T>(
4467 - previous: T,
4468 - current: T,
4469 - next: T,
4470 - ): [T, StartGesture] {
4471 - currentHookNameInDev = 'useSwipeTransition';
4472 - updateHookTypesDev();
4473 - return updateSwipeTransition(previous, current, next);
4474 - };
4475 - }
4250
4251 HooksDispatcherOnUpdateInDEV = {
4252 readContext<T>(context: ReactContext<T>): T {
@@ -4640,18 +4414,6 @@ if (__DEV__) {
4414 return updateEvent(callback);
4415 };
4416 }
4643 - if (enableSwipeTransition) {
4644 - (HooksDispatcherOnUpdateInDEV: Dispatcher).useSwipeTransition =
4645 - function useSwipeTransition<T>(
4646 - previous: T,
4647 - current: T,
4648 - next: T,
4649 - ): [T, StartGesture] {
4650 - currentHookNameInDev = 'useSwipeTransition';
4651 - updateHookTypesDev();
4652 - return updateSwipeTransition(previous, current, next);
4653 - };
4654 - }
4417
4418 HooksDispatcherOnRerenderInDEV = {
4419 readContext<T>(context: ReactContext<T>): T {
@@ -4819,18 +4581,6 @@ if (__DEV__) {
4581 return updateEvent(callback);
4582 };
4583 }
4822 - if (enableSwipeTransition) {
4823 - (HooksDispatcherOnRerenderInDEV: Dispatcher).useSwipeTransition =
4824 - function useSwipeTransition<T>(
4825 - previous: T,
4826 - current: T,
4827 - next: T,
4828 - ): [T, StartGesture] {
4829 - currentHookNameInDev = 'useSwipeTransition';
4830 - updateHookTypesDev();
4831 - return updateSwipeTransition(previous, current, next);
4832 - };
4833 - }
4584
4585 InvalidNestedHooksDispatcherOnMountInDEV = {
4586 readContext<T>(context: ReactContext<T>): T {
@@ -5023,19 +4773,6 @@ if (__DEV__) {
4773 return mountEvent(callback);
4774 };
4775 }
5026 - if (enableSwipeTransition) {
5027 - (InvalidNestedHooksDispatcherOnMountInDEV: Dispatcher).useSwipeTransition =
5028 - function useSwipeTransition<T>(
5029 - previous: T,
5030 - current: T,
5031 - next: T,
5032 - ): [T, StartGesture] {
5033 - currentHookNameInDev = 'useSwipeTransition';
5034 - warnInvalidHookAccess();
5035 - mountHookTypesDev();
5036 - return mountSwipeTransition(previous, current, next);
5037 - };
5038 - }
4776
4777 InvalidNestedHooksDispatcherOnUpdateInDEV = {
4778 readContext<T>(context: ReactContext<T>): T {
@@ -5228,19 +4965,6 @@ if (__DEV__) {
4965 return updateEvent(callback);
4966 };
4967 }
5231 - if (enableSwipeTransition) {
5232 - (InvalidNestedHooksDispatcherOnUpdateInDEV: Dispatcher).useSwipeTransition =
5233 - function useSwipeTransition<T>(
5234 - previous: T,
5235 - current: T,
5236 - next: T,
5237 - ): [T, StartGesture] {
5238 - currentHookNameInDev = 'useSwipeTransition';
5239 - warnInvalidHookAccess();
5240 - updateHookTypesDev();
5241 - return updateSwipeTransition(previous, current, next);
5242 - };
5243 - }
4968
4969 InvalidNestedHooksDispatcherOnRerenderInDEV = {
4970 readContext<T>(context: ReactContext<T>): T {
@@ -5433,17 +5157,4 @@ if (__DEV__) {
5157 return updateEvent(callback);
5158 };
5159 }
5436 - if (enableSwipeTransition) {
5437 - (InvalidNestedHooksDispatcherOnRerenderInDEV: Dispatcher).useSwipeTransition =
5438 - function useSwipeTransition<T>(
5439 - previous: T,
5440 - current: T,
5441 - next: T,
5442 - ): [T, StartGesture] {
5443 - currentHookNameInDev = 'useSwipeTransition';
5444 - warnInvalidHookAccess();
5445 - updateHookTypesDev();
5446 - return updateSwipeTransition(previous, current, next);
5447 - };
5448 - }
5160 }
packages/react-reconciler/src/ReactFiberRoot.js
+2 -2
@@ -33,7 +33,7 @@ import {
33 enableUpdaterTracking,
34 enableTransitionTracing,
35 disableLegacyMode,
36 - enableSwipeTransition,
36 + enableGestureTransition,
37 } from 'shared/ReactFeatureFlags';
38 import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue';
39 import {LegacyRoot, ConcurrentRoot} from './ReactRootTags';
@@ -98,7 +98,7 @@ function FiberRootNode(
98
99 this.formState = formState;
100
101 - if (enableSwipeTransition) {
101 + if (enableGestureTransition) {
102 this.pendingGestures = null;
103 this.stoppingGestures = null;
104 this.gestureClone = null;
packages/react-reconciler/src/ReactFiberRootScheduler.js
+3 -3
@@ -20,7 +20,7 @@ import {
20 enableComponentPerformanceTrack,
21 enableSiblingPrerendering,
22 enableYieldingBeforePassive,
23 - enableSwipeTransition,
23 + enableGestureTransition,
24 } from 'shared/ReactFeatureFlags';
25 import {
26 NoLane,
@@ -214,7 +214,7 @@ function flushSyncWorkAcrossRoots_impl(
214 );
215 if (
216 (includesSyncLane(nextLanes) ||
217 - (enableSwipeTransition && isGestureRender(nextLanes))) &&
217 + (enableGestureTransition && isGestureRender(nextLanes))) &&
218 !checkIfRootIsPrerendering(root, nextLanes)
219 ) {
220 // This root has pending sync work. Flush it now.
@@ -300,7 +300,7 @@ function processRootScheduleInMicrotask() {
300 // Common case: we're not treating any extra lanes as synchronous, so we
301 // can just check if the next lanes are sync.
302 includesSyncLane(nextLanes) ||
303 - (enableSwipeTransition && isGestureRender(nextLanes))
303 + (enableGestureTransition && isGestureRender(nextLanes))
304 ) {
305 mightHavePendingSyncWork = true;
306 }
packages/react-reconciler/src/ReactFiberTransition.js
+2 -2
@@ -20,7 +20,7 @@ import type {ScheduledGesture} from './ReactFiberGestureScheduler';
20
21 import {
22 enableTransitionTracing,
23 - enableSwipeTransition,
23 + enableGestureTransition,
24 } from 'shared/ReactFeatureFlags';
25 import {isPrimaryRenderer} from './ReactFiberConfig';
26 import {createCursor, push, pop} from './ReactFiberStack';
@@ -106,7 +106,7 @@ function chainGestureCancellation(
106 };
107 }
108
109 -if (enableSwipeTransition) {
109 +if (enableGestureTransition) {
110 const prevOnStartGestureTransitionFinish = ReactSharedInternals.G;
111 ReactSharedInternals.G = function onStartGestureTransitionFinishForReconciler(
112 transition: Transition,
packages/react-reconciler/src/ReactFiberWorkLoop.js
+10 -10
@@ -51,7 +51,7 @@ import {
51 enableYieldingBeforePassive,
52 enableThrottledScheduling,
53 enableViewTransition,
54 - enableSwipeTransition,
54 + enableGestureTransition,
55 } from 'shared/ReactFeatureFlags';
56 import {resetOwnerStackLimit} from 'shared/ReactOwnerStackReset';
57 import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -753,7 +753,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
753
754 const transition = requestCurrentTransition();
755 if (transition !== null) {
756 - if (enableSwipeTransition) {
756 + if (enableGestureTransition) {
757 if (transition.gesture) {
758 throw new Error(
759 'Cannot setState on regular state inside a startGestureTransition. ' +
@@ -1451,7 +1451,7 @@ function commitRootWhenReady(
1451 const subtreeFlags = finishedWork.subtreeFlags;
1452 const isViewTransitionEligible =
1453 enableViewTransition && includesOnlyViewTransitionEligibleLanes(lanes); // TODO: Use a subtreeFlag to optimize.
1454 - const isGestureTransition = enableSwipeTransition && isGestureRender(lanes);
1454 + const isGestureTransition = enableGestureTransition && isGestureRender(lanes);
1455 const maySuspendCommit =
1456 subtreeFlags & ShouldSuspendCommit ||
1457 (subtreeFlags & BothVisibilityAndMaySuspendCommit) ===
@@ -1470,7 +1470,7 @@ function commitRootWhenReady(
1470 if (isViewTransitionEligible || isGestureTransition) {
1471 // If we're stopping gestures we don't have to wait for any pending
1472 // view transition. We'll stop it when we commit.
1473 - if (!enableSwipeTransition || root.stoppingGestures === null) {
1473 + if (!enableGestureTransition || root.stoppingGestures === null) {
1474 suspendOnActiveViewTransition(root.containerInfo);
1475 }
1476 }
@@ -3297,7 +3297,7 @@ function commitRoot(
3297 if (enableSchedulingProfiler) {
3298 markCommitStopped();
3299 }
3300 - if (enableSwipeTransition) {
3300 + if (enableGestureTransition) {
3301 // Stop any gestures that were completed and is now being reverted.
3302 if (root.stoppingGestures !== null) {
3303 stopCompletedGestures(root);
@@ -3331,7 +3331,7 @@ function commitRoot(
3331 const concurrentlyUpdatedLanes = getConcurrentlyUpdatedLanes();
3332 remainingLanes = mergeLanes(remainingLanes, concurrentlyUpdatedLanes);
3333
3334 - if (enableSwipeTransition && root.pendingGestures === null) {
3334 + if (enableGestureTransition && root.pendingGestures === null) {
3335 // Gestures don't clear their lanes while the gesture is still active but it
3336 // might not be scheduled to do any more renders and so we shouldn't schedule
3337 // any more gesture lane work until a new gesture is scheduled.
@@ -3379,7 +3379,7 @@ function commitRoot(
3379 pendingSuspendedCommitReason = suspendedCommitReason;
3380 }
3381
3382 - if (enableSwipeTransition && isGestureRender(lanes)) {
3382 + if (enableGestureTransition && isGestureRender(lanes)) {
3383 // This is a special kind of render that doesn't commit regular effects.
3384 commitGestureOnRoot(
3385 root,
@@ -3505,7 +3505,7 @@ function commitRoot(
3505 }
3506
3507 let willStartViewTransition = shouldStartViewTransition;
3508 - if (enableSwipeTransition) {
3508 + if (enableGestureTransition) {
3509 // Stop any gestures that were completed and is now being committed.
3510 if (root.stoppingGestures !== null) {
3511 stopCompletedGestures(root);
@@ -3944,7 +3944,7 @@ function commitGestureOnRoot(
3944 }
3945
3946 function flushGestureMutations(): void {
3947 - if (!enableSwipeTransition) {
3947 + if (!enableGestureTransition) {
3948 return;
3949 }
3950 if (pendingEffectsStatus !== PENDING_GESTURE_MUTATION_PHASE) {
@@ -3973,7 +3973,7 @@ function flushGestureMutations(): void {
3973 }
3974
3975 function flushGestureAnimations(): void {
3976 - if (!enableSwipeTransition) {
3976 + if (!enableGestureTransition) {
3977 return;
3978 }
3979 // If we get canceled before we start we might not have applied
packages/react-reconciler/src/ReactInternalTypes.js
+2 -10
@@ -17,7 +17,6 @@ import type {
17 Awaited,
18 ReactComponentInfo,
19 ReactDebugInfo,
20 - StartGesture,
20 } from 'shared/ReactTypes';
21 import type {WorkTag} from './ReactWorkTags';
22 import type {TypeOfMode} from './ReactTypeOfMode';
@@ -61,8 +60,7 @@ export type HookType =
60 | 'useCacheRefresh'
61 | 'useOptimistic'
62 | 'useFormState'
64 - | 'useActionState'
65 - | 'useSwipeTransition';
63 + | 'useActionState';
64
65 export type ContextDependency<T> = {
66 context: ReactContext<T>,
@@ -282,7 +280,7 @@ type BaseFiberRootProperties = {
280
281 formState: ReactFormState<any, any> | null,
282
285 - // enableSwipeTransition only
283 + // enableGestureTransition only
284 pendingGestures: null | ScheduledGesture,
285 stoppingGestures: null | ScheduledGesture,
286 gestureClone: null | Instance,
@@ -446,12 +444,6 @@ export type Dispatcher = {
444 initialState: Awaited<S>,
445 permalink?: string,
446 ) => [Awaited<S>, (P) => void, boolean],
449 - // TODO: Non-nullable once `enableSwipeTransition` is on everywhere.
450 - useSwipeTransition?: <T>(
451 - previous: T,
452 - current: T,
453 - next: T,
454 - ) => [T, StartGesture],
447 };
448
449 export type AsyncDispatcher = {
packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
-2
@@ -157,8 +157,6 @@ export const startViewTransition = $$$config.startViewTransition;
157 export const startGestureTransition = $$$config.startGestureTransition;
158 export const stopViewTransition = $$$config.stopViewTransition;
159 export const getCurrentGestureOffset = $$$config.getCurrentGestureOffset;
160 -export const subscribeToGestureDirection =
161 - $$$config.subscribeToGestureDirection;
160 export const createViewTransitionInstance =
161 $$$config.createViewTransitionInstance;
162 export const clearContainer = $$$config.clearContainer;
packages/react-server/src/ReactFizzHooks.js
+1 -23
@@ -16,7 +16,6 @@ import type {
16 Usable,
17 ReactCustomFormAction,
18 Awaited,
19 - StartGesture,
19 } from 'shared/ReactTypes';
20
21 import type {ResumableState} from './ReactFizzConfig';
@@ -39,10 +38,7 @@ import {
38 } from './ReactFizzConfig';
39 import {createFastHash} from './ReactServerStreamConfig';
40
42 -import {
43 - enableUseEffectEventHook,
44 - enableSwipeTransition,
45 -} from 'shared/ReactFeatureFlags';
41 +import {enableUseEffectEventHook} from 'shared/ReactFeatureFlags';
42 import is from 'shared/objectIs';
43 import {
44 REACT_CONTEXT_TYPE,
@@ -799,19 +795,6 @@ function useMemoCache(size: number): Array<mixed> {
795 return data;
796 }
797
802 -function unsupportedStartGesture() {
803 - throw new Error('startGesture cannot be called during server rendering.');
804 -}
805 -
806 -function useSwipeTransition<T>(
807 - previous: T,
808 - current: T,
809 - next: T,
810 -): [T, StartGesture] {
811 - resolveCurrentlyRenderingComponent();
812 - return [current, unsupportedStartGesture];
813 -}
814 -
798 function noop(): void {}
799
800 function clientHookNotSupported() {
@@ -880,11 +863,6 @@ export const HooksDispatcher: Dispatcher = supportsClientAPIs
863 if (enableUseEffectEventHook) {
864 HooksDispatcher.useEffectEvent = useEffectEvent;
865 }
883 -if (enableSwipeTransition) {
884 - HooksDispatcher.useSwipeTransition = supportsClientAPIs
885 - ? useSwipeTransition
886 - : clientHookNotSupported;
887 -}
866
867 export let currentResumableState: null | ResumableState = (null: any);
868 export function setCurrentResumableState(
packages/react-server/src/ReactFlightHooks.js
+1 -7
@@ -17,10 +17,7 @@ import {
17 } from 'shared/ReactSymbols';
18 import {createThenableState, trackUsedThenable} from './ReactFlightThenable';
19 import {isClientReference} from './ReactFlightServerConfig';
20 -import {
21 - enableUseEffectEventHook,
22 - enableSwipeTransition,
23 -} from 'shared/ReactFeatureFlags';
20 +import {enableUseEffectEventHook} from 'shared/ReactFeatureFlags';
21
22 let currentRequest = null;
23 let thenableIndexCounter = 0;
@@ -102,9 +99,6 @@ export const HooksDispatcher: Dispatcher = {
99 if (enableUseEffectEventHook) {
100 HooksDispatcher.useEffectEvent = (unsupportedHook: any);
101 }
105 -if (enableSwipeTransition) {
106 - HooksDispatcher.useSwipeTransition = (unsupportedHook: any);
107 -}
102
103 function unsupportedHook(): void {
104 throw new Error('This Hook is not supported in Server Components.');
packages/react-test-renderer/src/ReactFiberConfigTestHost.js
-8
@@ -501,14 +501,6 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number {
501 return 0;
502 }
503
504 -export function subscribeToGestureDirection(
505 - provider: GestureTimeline,
506 - currentOffset: number,
507 - directionCallback: (direction: boolean) => void,
508 -): () => void {
509 - return () => {};
510 -}
511 -
504 export function beforeActiveInstanceBlur(internalInstanceHandle: Object) {
505 // noop
506 }
packages/react/index.experimental.development.js
-1
@@ -34,7 +34,6 @@ export {
34 unstable_SuspenseList,
35 unstable_ViewTransition,
36 unstable_startGestureTransition,
37 - unstable_useSwipeTransition,
37 unstable_addTransitionType,
38 unstable_useCacheRefresh,
39 useId,
packages/react/index.experimental.js
-1
@@ -34,7 +34,6 @@ export {
34 unstable_SuspenseList,
35 unstable_ViewTransition,
36 unstable_startGestureTransition,
37 - unstable_useSwipeTransition,
37 unstable_addTransitionType,
38 unstable_useCacheRefresh,
39 useId,
packages/react/src/ReactClient.js
+1 -3
@@ -57,7 +57,6 @@ import {
57 use,
58 useOptimistic,
59 useActionState,
60 - useSwipeTransition,
60 } from './ReactHooks';
61 import ReactSharedInternals from './ReactSharedInternalsClient';
62 import {startTransition, startGestureTransition} from './ReactStartTransition';
@@ -127,9 +126,8 @@ export {
126 // enableViewTransition
127 REACT_VIEW_TRANSITION_TYPE as unstable_ViewTransition,
128 addTransitionType as unstable_addTransitionType,
130 - // enableSwipeTransition
129 + // enableGestureTransition
130 startGestureTransition as unstable_startGestureTransition,
132 - useSwipeTransition as unstable_useSwipeTransition,
131 // DEV-only
132 useId,
133 act,
packages/react/src/ReactHooks.js
-16
@@ -13,14 +13,11 @@ import type {
13 StartTransitionOptions,
14 Usable,
15 Awaited,
16 - StartGesture,
16 } from 'shared/ReactTypes';
17 import {REACT_CONSUMER_TYPE} from 'shared/ReactSymbols';
18
19 import ReactSharedInternals from 'shared/ReactSharedInternals';
20
22 -import {enableSwipeTransition} from 'shared/ReactFeatureFlags';
23 -
21 type BasicStateAction<S> = (S => S) | S;
22 type Dispatch<A> = A => void;
23
@@ -242,16 +239,3 @@ export function useActionState<S, P>(
239 const dispatcher = resolveDispatcher();
240 return dispatcher.useActionState(action, initialState, permalink);
241 }
245 -
246 -export function useSwipeTransition<T>(
247 - previous: T,
248 - current: T,
249 - next: T,
250 -): [T, StartGesture] {
251 - if (!enableSwipeTransition) {
252 - throw new Error('Not implemented.');
253 - }
254 - const dispatcher = resolveDispatcher();
255 - // $FlowFixMe[not-a-function] This is unstable, thus optional
256 - return dispatcher.useSwipeTransition(previous, current, next);
257 -}
packages/react/src/ReactSharedInternalsClient.js
+2 -2
@@ -15,7 +15,7 @@ import type {GestureProvider, GestureOptions} from 'shared/ReactTypes';
15
16 import {
17 enableViewTransition,
18 - enableSwipeTransition,
18 + enableGestureTransition,
19 } from 'shared/ReactFeatureFlags';
20
21 export type SharedStateClient = {
@@ -58,7 +58,7 @@ const ReactSharedInternals: SharedStateClient = ({
58 T: null,
59 S: null,
60 }: any);
61 -if (enableSwipeTransition) {
61 +if (enableGestureTransition) {
62 ReactSharedInternals.G = null;
63 }
64 if (enableViewTransition) {
packages/react/src/ReactStartTransition.js
+6 -6
@@ -18,13 +18,13 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
18
19 import {
20 enableTransitionTracing,
21 - enableSwipeTransition,
21 + enableGestureTransition,
22 } from 'shared/ReactFeatureFlags';
23
24 import reportGlobalError from 'shared/reportGlobalError';
25
26 export type Transition = {
27 - gesture: null | GestureProvider, // enableSwipeTransition
27 + gesture: null | GestureProvider, // enableGestureTransition
28 name: null | string, // enableTransitionTracing only
29 startTime: number, // enableTransitionTracing only
30 _updatedFibers: Set<Fiber>, // DEV-only
@@ -37,7 +37,7 @@ export function startTransition(
37 ): void {
38 const prevTransition = ReactSharedInternals.T;
39 const currentTransition: Transition = ({}: any);
40 - if (enableSwipeTransition) {
40 + if (enableGestureTransition) {
41 currentTransition.gesture = null;
42 }
43 if (enableTransitionTracing) {
@@ -76,10 +76,10 @@ export function startGestureTransition(
76 scope: () => void,
77 options?: GestureOptions & StartTransitionOptions,
78 ): () => void {
79 - if (!enableSwipeTransition) {
79 + if (!enableGestureTransition) {
80 // eslint-disable-next-line react-internal/prod-error-codes
81 throw new Error(
82 - 'startGestureTransition should not be exported when the enableSwipeTransition flag is off.',
82 + 'startGestureTransition should not be exported when the enableGestureTransition flag is off.',
83 );
84 }
85 if (provider == null) {
@@ -92,7 +92,7 @@ export function startGestureTransition(
92 }
93 const prevTransition = ReactSharedInternals.T;
94 const currentTransition: Transition = ({}: any);
95 - if (enableSwipeTransition) {
95 + if (enableGestureTransition) {
96 currentTransition.gesture = provider;
97 }
98 if (enableTransitionTracing) {
packages/shared/ReactFeatureFlags.js
+1 -1
@@ -92,7 +92,7 @@ export const enableHalt = __EXPERIMENTAL__;
92
93 export const enableViewTransition = __EXPERIMENTAL__;
94
95 -export const enableSwipeTransition = __EXPERIMENTAL__;
95 +export const enableGestureTransition = __EXPERIMENTAL__;
96
97 export const enableScrollEndPolyfill = __EXPERIMENTAL__;
98
packages/shared/ReactTypes.js
-5
@@ -171,11 +171,6 @@ export type ReactFormState<S, ReferenceId> = [
171 // renderer supports it.
172 export type GestureProvider = any;
173
174 -export type StartGesture = (
175 - gestureProvider: GestureProvider,
176 - gestureOptions: GestureOptions,
177 -) => () => void;
178 -
174 export type GestureOptions = {
175 direction?: 'previous' | 'next',
176 range?: [/*previous*/ number, /*current*/ number, /*next*/ number],
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1 -1
@@ -80,7 +80,7 @@ export const enableHydrationLaneScheduling = true;
80 export const enableYieldingBeforePassive = false;
81 export const enableThrottledScheduling = false;
82 export const enableViewTransition = false;
83 -export const enableSwipeTransition = false;
83 +export const enableGestureTransition = false;
84 export const enableScrollEndPolyfill = true;
85 export const enableFragmentRefs = false;
86 export const ownerStackLimit = 1e4;
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1 -1
@@ -70,7 +70,7 @@ export const enableYieldingBeforePassive = false;
70
71 export const enableThrottledScheduling = false;
72 export const enableViewTransition = false;
73 -export const enableSwipeTransition = false;
73 +export const enableGestureTransition = false;
74 export const enableFastAddPropertiesInDiffing = false;
75 export const enableLazyPublicInstanceInFabric = false;
76 export const enableScrollEndPolyfill = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1 -1
@@ -69,7 +69,7 @@ export const enableYieldingBeforePassive = true;
69
70 export const enableThrottledScheduling = false;
71 export const enableViewTransition = false;
72 -export const enableSwipeTransition = false;
72 +export const enableGestureTransition = false;
73 export const enableFastAddPropertiesInDiffing = true;
74 export const enableLazyPublicInstanceInFabric = false;
75 export const enableScrollEndPolyfill = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
+1 -1
@@ -66,7 +66,7 @@ export const enableHydrationLaneScheduling = true;
66 export const enableYieldingBeforePassive = false;
67 export const enableThrottledScheduling = false;
68 export const enableViewTransition = false;
69 -export const enableSwipeTransition = false;
69 +export const enableGestureTransition = false;
70 export const enableFastAddPropertiesInDiffing = false;
71 export const enableLazyPublicInstanceInFabric = false;
72 export const enableScrollEndPolyfill = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1 -1
@@ -80,7 +80,7 @@ export const enableYieldingBeforePassive = false;
80
81 export const enableThrottledScheduling = false;
82 export const enableViewTransition = false;
83 -export const enableSwipeTransition = false;
83 +export const enableGestureTransition = false;
84 export const enableFastAddPropertiesInDiffing = false;
85 export const enableLazyPublicInstanceInFabric = false;
86 export const enableScrollEndPolyfill = true;
packages/shared/forks/ReactFeatureFlags.www.js
+1 -1
@@ -111,7 +111,7 @@ export const enableShallowPropDiffing = false;
111
112 export const enableLazyPublicInstanceInFabric = false;
113
114 -export const enableSwipeTransition = false;
114 +export const enableGestureTransition = false;
115
116 export const ownerStackLimit = 1e4;
117
scripts/error-codes/codes.json
+3 -3
@@ -535,9 +535,9 @@
535 "547": "startGesture cannot be called during server rendering.",
536 "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.",
537 "549": "Cannot start a gesture with a disconnected AnimationTimeline.",
538 - "550": "useSwipeTransition is not yet supported in react-art.",
539 - "551": "useSwipeTransition is not yet supported in React Native.",
540 - "552": "Cannot use a useSwipeTransition() in a detached root.",
538 + "550": "startGestureTransition is not yet supported in react-art.",
539 + "551": "startGestureTransition is not yet supported in React Native.",
540 + "552": "Cannot use a startGestureTransition() on a detached root.",
541 "553": "A Timeline is required as the first argument to startGestureTransition.",
542 "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.",
543 "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."