diff --git a/packages/react-native/Libraries/Animated/Animated.js b/packages/react-native/Libraries/Animated/Animated.js index ec17ef764543ee..a9df993ad2981c 100644 --- a/packages/react-native/Libraries/Animated/Animated.js +++ b/packages/react-native/Libraries/Animated/Animated.js @@ -21,7 +21,7 @@ import Platform from '../Utilities/Platform'; import AnimatedImplementation from './AnimatedImplementation'; import AnimatedMock from './AnimatedMock'; -const Animated = ((Platform.isTesting +const Animated = ((Platform.isDisableAnimations ? AnimatedMock : AnimatedImplementation): typeof AnimatedImplementation); diff --git a/packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js b/packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js index e4489d0543bf60..6283e673c64846 100644 --- a/packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js @@ -49,7 +49,7 @@ function configureNext( onAnimationDidEnd?: OnAnimationDidEndCallback, onAnimationDidFail?: OnAnimationDidFailCallback, ) { - if (Platform.isTesting) { + if (Platform.isDisableAnimations) { return; } diff --git a/packages/react-native/Libraries/Utilities/NativePlatformConstantsAndroid.js b/packages/react-native/Libraries/Utilities/NativePlatformConstantsAndroid.js index e1329e8c5896b6..b470f9b350ec7f 100644 --- a/packages/react-native/Libraries/Utilities/NativePlatformConstantsAndroid.js +++ b/packages/react-native/Libraries/Utilities/NativePlatformConstantsAndroid.js @@ -15,6 +15,7 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { +getConstants: () => {| isTesting: boolean, + isDisableAnimations?: boolean, reactNativeVersion: {| major: number, minor: number, diff --git a/packages/react-native/Libraries/Utilities/NativePlatformConstantsIOS.js b/packages/react-native/Libraries/Utilities/NativePlatformConstantsIOS.js index cf60d5ec984877..c1defa9981f0c1 100644 --- a/packages/react-native/Libraries/Utilities/NativePlatformConstantsIOS.js +++ b/packages/react-native/Libraries/Utilities/NativePlatformConstantsIOS.js @@ -15,6 +15,7 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { +getConstants: () => {| isTesting: boolean, + isDisableAnimations?: boolean, reactNativeVersion: {| major: number, minor: number, diff --git a/packages/react-native/Libraries/Utilities/Platform.android.js b/packages/react-native/Libraries/Utilities/Platform.android.js index 29234be81a7baa..3d4b9e40f545bb 100644 --- a/packages/react-native/Libraries/Utilities/Platform.android.js +++ b/packages/react-native/Libraries/Utilities/Platform.android.js @@ -28,6 +28,7 @@ const Platform = { // $FlowFixMe[unsafe-getters-setters] get constants(): {| isTesting: boolean, + isDisableAnimations?: boolean, reactNativeVersion: {| major: number, minor: number, @@ -61,6 +62,11 @@ const Platform = { return false; }, // $FlowFixMe[unsafe-getters-setters] + get isDisableAnimations(): boolean { + // $FlowFixMe[object-this-reference] + return this.constants.isDisableAnimations ?? this.isTesting; + }, + // $FlowFixMe[unsafe-getters-setters] get isTV(): boolean { // $FlowFixMe[object-this-reference] return this.constants.uiMode === 'tv'; diff --git a/packages/react-native/Libraries/Utilities/Platform.d.ts b/packages/react-native/Libraries/Utilities/Platform.d.ts index 465a82b35c6df1..1ff836839110be 100644 --- a/packages/react-native/Libraries/Utilities/Platform.d.ts +++ b/packages/react-native/Libraries/Utilities/Platform.d.ts @@ -19,6 +19,7 @@ export type PlatformOSType = | 'native'; type PlatformConstants = { isTesting: boolean; + isDisableAnimations?: boolean | undefined; reactNativeVersion: { major: number; minor: number; diff --git a/packages/react-native/Libraries/Utilities/Platform.ios.js b/packages/react-native/Libraries/Utilities/Platform.ios.js index 4adf4201c52b3e..4d0217a80945f4 100644 --- a/packages/react-native/Libraries/Utilities/Platform.ios.js +++ b/packages/react-native/Libraries/Utilities/Platform.ios.js @@ -30,6 +30,7 @@ const Platform = { forceTouchAvailable: boolean, interfaceIdiom: string, isTesting: boolean, + isDisableAnimations?: boolean, osVersion: string, reactNativeVersion: {| major: number, @@ -65,6 +66,11 @@ const Platform = { } return false; }, + // $FlowFixMe[unsafe-getters-setters] + get isDisableAnimations(): boolean { + // $FlowFixMe[object-this-reference] + return this.constants.isDisableAnimations ?? this.isTesting; + }, select: (spec: PlatformSelectSpec): T => // $FlowFixMe[incompatible-return] 'ios' in spec ? spec.ios : 'native' in spec ? spec.native : spec.default,