From 2204ec94d4b67a9ba559db3f54a5a1ef91e0f233 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 14 Jan 2025 11:05:07 -0800 Subject: [PATCH] fix Pressable when transform style is animated (#48672) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48672 ## Changelog: [General] [Fixed] - Buttons becoming unresponsive when transform is animated # The problem D67872307 changes when `ensureUpdateSubscriptionExists` is called to in `__attach`. This breaks the functionality because `__attach` is called before flag `__isNative` is set and subscriptions are never setup. # Fix The diff sets up subscriptions in `__makeNative` method. Reviewed By: yungsters Differential Revision: D68154908 fbshipit-source-id: e2ac108b064a66dda08902653d6bd20286f92458 --- .../react-native/Libraries/Animated/nodes/AnimatedValue.js | 6 ++++++ .../__tests__/__snapshots__/public-api-test.js.snap | 1 + 2 files changed, 7 insertions(+) diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js b/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js index 889bfa51825e1c..2e500bf64b480d 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedValue.js @@ -9,6 +9,7 @@ */ import type {EventSubscription} from '../../vendor/emitter/EventEmitter'; +import type {PlatformConfig} from '../AnimatedPlatformConfig'; import type Animation, {EndCallback} from '../animations/Animation'; import type {InterpolationConfigType} from './AnimatedInterpolation'; import type AnimatedNode from './AnimatedNode'; @@ -131,6 +132,11 @@ export default class AnimatedValue extends AnimatedWithChildren { return this._value + this._offset; } + __makeNative(platformConfig: ?PlatformConfig): void { + super.__makeNative(platformConfig); + this.#ensureUpdateSubscriptionExists(); + } + #ensureUpdateSubscriptionExists(): void { if (this.#updateSubscription != null) { return; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 205551403b9648..d34ea1c58456eb 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1109,6 +1109,7 @@ declare export default class AnimatedValue extends AnimatedWithChildren { __attach(): void; __detach(): void; __getValue(): number; + __makeNative(platformConfig: ?PlatformConfig): void; setValue(value: number): void; setOffset(offset: number): void; flattenOffset(): void;