diff --git a/packages/react-native/Libraries/Animated/__tests__/Animated-test.js b/packages/react-native/Libraries/Animated/__tests__/Animated-test.js
index 2b7a43c95e7..2853ffdfcc1 100644
--- a/packages/react-native/Libraries/Animated/__tests__/Animated-test.js
+++ b/packages/react-native/Libraries/Animated/__tests__/Animated-test.js
@@ -31,12 +31,8 @@ function mockQueueMicrotask() {
}
describe('Animated', () => {
- let ReactNativeFeatureFlags;
-
beforeEach(() => {
jest.resetModules();
-
- ReactNativeFeatureFlags = require('../../../src/private/featureflags/ReactNativeFeatureFlags');
});
mockQueueMicrotask();
@@ -113,50 +109,7 @@ describe('Animated', () => {
expect(callback.mock.calls.length).toBe(1);
});
- it('does not detach on updates', async () => {
- ReactNativeFeatureFlags.override({
- scheduleAnimatedCleanupInMicrotask: () => false,
- });
-
- const opacity = new Animated.Value(0);
- jest.spyOn(opacity, '__detach');
-
- const root = await create();
- expect(opacity.__detach).not.toBeCalled();
-
- await update(root, );
- expect(opacity.__detach).not.toBeCalled();
-
- await unmount(root);
- expect(opacity.__detach).toBeCalled();
- });
-
- it('stops animation when detached', async () => {
- ReactNativeFeatureFlags.override({
- scheduleAnimatedCleanupInMicrotask: () => false,
- });
-
- const opacity = new Animated.Value(0);
- const callback = jest.fn();
-
- const root = await create();
-
- Animated.timing(opacity, {
- toValue: 10,
- duration: 1000,
- useNativeDriver: false,
- }).start(callback);
-
- await unmount(root);
-
- expect(callback).toBeCalledWith({finished: false});
- });
-
it('detaches only on unmount (in a microtask)', async () => {
- ReactNativeFeatureFlags.override({
- scheduleAnimatedCleanupInMicrotask: () => true,
- });
-
const opacity = new Animated.Value(0);
jest.spyOn(opacity, '__detach');
@@ -175,10 +128,6 @@ describe('Animated', () => {
});
it('restores default values only on update (in a microtask)', async () => {
- ReactNativeFeatureFlags.override({
- scheduleAnimatedCleanupInMicrotask: () => true,
- });
-
const __restoreDefaultValues = jest.spyOn(
AnimatedProps.prototype,
'__restoreDefaultValues',
@@ -213,10 +162,6 @@ describe('Animated', () => {
});
it('stops animation when detached (in a microtask)', async () => {
- ReactNativeFeatureFlags.override({
- scheduleAnimatedCleanupInMicrotask: () => true,
- });
-
const opacity = new Animated.Value(0);
const callback = jest.fn();
diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
index ffea499db9b..fca0d50a93a 100644
--- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
+++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
@@ -783,16 +783,6 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
- scheduleAnimatedCleanupInMicrotask: {
- defaultValue: true,
- metadata: {
- description:
- 'Changes the cleanup of `AnimatedProps` to occur in a microtask instead of synchronously during effect cleanup (for unmount) or subsequent mounts (for updates).',
- expectedReleaseValue: true,
- purpose: 'release',
- },
- ossReleaseStage: 'none',
- },
shouldUseAnimatedObjectForTransform: {
defaultValue: false,
metadata: {
diff --git a/packages/react-native/src/private/animated/createAnimatedPropsHook.js b/packages/react-native/src/private/animated/createAnimatedPropsHook.js
index 072fdea2510..6c674f1728b 100644
--- a/packages/react-native/src/private/animated/createAnimatedPropsHook.js
+++ b/packages/react-native/src/private/animated/createAnimatedPropsHook.js
@@ -89,13 +89,6 @@ export default function createAnimatedPropsHook(
};
});
- // NOTE: This feature flag must be evaluated inside the hook because this
- // module factory can be evaluated much sooner, before overrides are set.
- const useAnimatedPropsLifecycle =
- ReactNativeFeatureFlags.scheduleAnimatedCleanupInMicrotask()
- ? useAnimatedPropsLifecycleWithCleanupInMicrotask
- : useAnimatedPropsLifecycleWithPrevNodeRef;
-
useAnimatedPropsLifecycle(node);
// TODO: This "effect" does three things:
@@ -262,44 +255,6 @@ function addAnimatedValuesListenersToProps(
}
}
-/**
- * Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
- * and `__detach`. However, this is more complicated because `AnimatedProps`
- * uses reference counting to determine when to recursively detach its children
- * nodes. So in order to optimize this, we avoid detaching until the next attach
- * unless we are unmounting.
- */
-function useAnimatedPropsLifecycleWithPrevNodeRef(node: AnimatedProps): void {
- const prevNodeRef = useRef(null);
- const isUnmountingRef = useRef(false);
-
- useInsertionEffect(() => {
- isUnmountingRef.current = false;
- return () => {
- isUnmountingRef.current = true;
- };
- }, []);
-
- useInsertionEffect(() => {
- node.__attach();
- if (prevNodeRef.current != null) {
- const prevNode = prevNodeRef.current;
- // TODO: Stop restoring default values (unless `reset` is called).
- prevNode.__restoreDefaultValues();
- prevNode.__detach();
- prevNodeRef.current = null;
- }
- return () => {
- if (isUnmountingRef.current) {
- // NOTE: Do not restore default values on unmount, see D18197735.
- node.__detach();
- } else {
- prevNodeRef.current = node;
- }
- };
- }, [node]);
-}
-
/**
* Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
* and `__detach`. However, `__detach` occurs in a microtask for these reasons:
@@ -314,9 +269,7 @@ function useAnimatedPropsLifecycleWithPrevNodeRef(node: AnimatedProps): void {
* callbacks may update state, which is unsupported and will force synchronous
* updates.
*/
-function useAnimatedPropsLifecycleWithCleanupInMicrotask(
- node: AnimatedProps,
-): void {
+function useAnimatedPropsLifecycle(node: AnimatedProps): void {
const isMounted = useRef(false);
useInsertionEffect(() => {
diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
index 13712805de4..d5d72cac560 100644
--- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
+++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
- * @generated SignedSource<<99d6ed3c0a9bfd543d58de5b2fdfffdf>>
+ * @generated SignedSource<>
* @flow strict
* @noformat
*/
@@ -36,7 +36,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
fixVirtualizeListCollapseWindowSize: Getter,
isLayoutAnimationEnabled: Getter,
reduceDefaultPropsInView: Getter,
- scheduleAnimatedCleanupInMicrotask: Getter,
shouldUseAnimatedObjectForTransform: Getter,
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter,
shouldUseSetNativePropsInFabric: Getter,
@@ -152,11 +151,6 @@ export const isLayoutAnimationEnabled: Getter = createJavaScriptFlagGet
*/
export const reduceDefaultPropsInView: Getter = createJavaScriptFlagGetter('reduceDefaultPropsInView', true);
-/**
- * Changes the cleanup of `AnimatedProps` to occur in a microtask instead of synchronously during effect cleanup (for unmount) or subsequent mounts (for updates).
- */
-export const scheduleAnimatedCleanupInMicrotask: Getter = createJavaScriptFlagGetter('scheduleAnimatedCleanupInMicrotask', true);
-
/**
* Enables use of AnimatedObject for animating transform values.
*/