From 458cd06bdbbeb905729e20773ecf45b087e1cedf Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 19 Sep 2025 05:10:47 -0700 Subject: [PATCH] RN: Remove References to `InteractionManager` (#53830) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53830 Now that `InteractionManager` is deprecated (and no-ops), this removes all remaining references to it — in `Animated` and `PanResponder` — from the React Native repository. Changelog: [Internal] Reviewed By: javache Differential Revision: D82690242 fbshipit-source-id: d101d47d1f8640f70e2d199492d4345b63663251 --- .../Animated/__tests__/Animated-test.js | 50 ---------------- .../Libraries/Animated/nodes/AnimatedValue.js | 8 --- .../Libraries/Interaction/PanResponder.js | 57 ++----------------- 3 files changed, 6 insertions(+), 109 deletions(-) diff --git a/packages/react-native/Libraries/Animated/__tests__/Animated-test.js b/packages/react-native/Libraries/Animated/__tests__/Animated-test.js index 9a85755974e..12d72c0f722 100644 --- a/packages/react-native/Libraries/Animated/__tests__/Animated-test.js +++ b/packages/react-native/Libraries/Animated/__tests__/Animated-test.js @@ -873,56 +873,6 @@ describe('Animated', () => { }); }); - describe('Animated Interactions', () => { - let Animated; // eslint-disable-line no-shadow - let InteractionManager; - - beforeEach(() => { - jest.mock('../../Interaction/InteractionManager'); - Animated = require('../Animated').default; - InteractionManager = - require('../../Interaction/InteractionManager').default; - }); - - afterEach(() => { - jest.unmock('../../Interaction/InteractionManager'); - }); - - it('registers an interaction by default', () => { - // $FlowFixMe[prop-missing] - InteractionManager.createInteractionHandle.mockReturnValue(777); - - const value = new Animated.Value(0); - const callback = jest.fn(); - Animated.timing(value, { - toValue: 100, - duration: 100, - useNativeDriver: false, - }).start(callback); - jest.runAllTimers(); - - expect(InteractionManager.createInteractionHandle).toBeCalled(); - expect(InteractionManager.clearInteractionHandle).toBeCalledWith(777); - expect(callback).toBeCalledWith({finished: true}); - }); - - it('does not register an interaction when specified', () => { - const value = new Animated.Value(0); - const callback = jest.fn(); - Animated.timing(value, { - toValue: 100, - duration: 100, - isInteraction: false, - useNativeDriver: false, - }).start(callback); - jest.runAllTimers(); - - expect(InteractionManager.createInteractionHandle).not.toBeCalled(); - expect(InteractionManager.clearInteractionHandle).not.toBeCalled(); - expect(callback).toBeCalledWith({finished: true}); - }); - }); - describe('Animated Tracking', () => { it('should track values', () => { const value1 = new Animated.Value(0); diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js b/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js index 455709d4333..6699021fe79 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js @@ -18,7 +18,6 @@ import type {AnimatedNodeConfig} from './AnimatedNode'; import type AnimatedTracking from './AnimatedTracking'; import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper'; -import InteractionManager from '../../Interaction/InteractionManager'; import AnimatedInterpolation from './AnimatedInterpolation'; import AnimatedWithChildren from './AnimatedWithChildren'; @@ -312,10 +311,6 @@ export default class AnimatedValue extends AnimatedWithChildren { * See https://reactnative.dev/docs/animatedvalue#animate */ animate(animation: Animation, callback: ?EndCallback): void { - let handle = null; - if (animation.__isInteraction) { - handle = InteractionManager.createInteractionHandle(); - } const previousAnimation = this._animation; this._animation && this._animation.stop(); this._animation = animation; @@ -328,9 +323,6 @@ export default class AnimatedValue extends AnimatedWithChildren { }, result => { this._animation = null; - if (handle !== null) { - InteractionManager.clearInteractionHandle(handle); - } callback && callback(result); }, previousAnimation, diff --git a/packages/react-native/Libraries/Interaction/PanResponder.js b/packages/react-native/Libraries/Interaction/PanResponder.js index ecef477dd25..1a38656aec0 100644 --- a/packages/react-native/Libraries/Interaction/PanResponder.js +++ b/packages/react-native/Libraries/Interaction/PanResponder.js @@ -12,7 +12,6 @@ import type {GestureResponderEvent} from '../Types/CoreEventTypes'; -const InteractionManager = require('./InteractionManager').default; const TouchHistoryMath = require('./TouchHistoryMath').default; const currentCentroidXOfTouchesChangedAfter = @@ -31,9 +30,6 @@ const currentCentroidY = TouchHistoryMath.currentCentroidY; * single-touch gestures resilient to extra touches, and can be used to * recognize simple multi-touch gestures. * - * By default, `PanResponder` holds an `InteractionManager` handle to block - * long-running JS events from interrupting active gestures. - * * It provides a predictable wrapper of the responder handlers provided by the * [gesture responder system](docs/gesture-responder-system.html). * For each handler, it provides a new `gestureState` object alongside the @@ -405,9 +401,6 @@ const PanResponder = { getInteractionHandle: () => ?number, panHandlers: GestureResponderHandlerMethods, } { - const interactionState = { - handle: (null: ?number), - }; const gestureState: PanResponderGestureState = { // Useful for debugging stateID: Math.random(), @@ -464,10 +457,6 @@ const PanResponder = { }, onResponderGrant(event: GestureResponderEvent): boolean { - if (!interactionState.handle) { - interactionState.handle = - InteractionManager.createInteractionHandle(); - } gestureState.x0 = currentCentroidX(event.touchHistory); gestureState.y0 = currentCentroidY(event.touchHistory); gestureState.dx = 0; @@ -482,21 +471,11 @@ const PanResponder = { }, onResponderReject(event: GestureResponderEvent): void { - clearInteractionHandle( - interactionState, - config.onPanResponderReject, - event, - gestureState, - ); + config.onPanResponderReject?.call(undefined, event, gestureState); }, onResponderRelease(event: GestureResponderEvent): void { - clearInteractionHandle( - interactionState, - config.onPanResponderRelease, - event, - gestureState, - ); + config.onPanResponderRelease?.call(undefined, event, gestureState); PanResponder._initializeGestureState(gestureState); }, @@ -529,21 +508,11 @@ const PanResponder = { onResponderEnd(event: GestureResponderEvent): void { const touchHistory = event.touchHistory; gestureState.numberActiveTouches = touchHistory.numberActiveTouches; - clearInteractionHandle( - interactionState, - config.onPanResponderEnd, - event, - gestureState, - ); + config.onPanResponderEnd?.call(undefined, event, gestureState); }, onResponderTerminate(event: GestureResponderEvent): void { - clearInteractionHandle( - interactionState, - config.onPanResponderTerminate, - event, - gestureState, - ); + config.onPanResponderTerminate?.call(undefined, event, gestureState); PanResponder._initializeGestureState(gestureState); }, @@ -556,27 +525,13 @@ const PanResponder = { return { panHandlers, getInteractionHandle(): ?number { - return interactionState.handle; + // TODO: Deprecate and delete this method. + return null; }, }; }, }; -function clearInteractionHandle( - interactionState: {handle: ?number, ...}, - callback: ?(ActiveCallback | PassiveCallback), - event: GestureResponderEvent, - gestureState: PanResponderGestureState, -) { - if (interactionState.handle) { - InteractionManager.clearInteractionHandle(interactionState.handle); - interactionState.handle = null; - } - if (callback) { - callback(event, gestureState); - } -} - export type PanResponderInstance = ReturnType<(typeof PanResponder)['create']>; export default PanResponder;