From 94a5f31763f032e36b229803d176527e61f7c14a Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Mon, 16 Sep 2024 01:03:46 -0700 Subject: [PATCH] Delete redundant calls to flushQueue (#46327) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46327 The operation queue for Animated is flushed after the animation is started: [unsetWaitingForIdentifier](https://www.internalfb.com/code/fbsource/[6a3ea67be1490a510f47d57be2e049253c81bdae]/xplat/js/react-native-github/packages/react-native/Libraries/Animated/animations/Animation.js?lines=131) -> [disableQueue](https://www.internalfb.com/code/fbsource/[6a3ea67be1490a510f47d57be2e049253c81bdae]/xplat/js/react-native-github/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js?lines=128) -> [flushQueue](https://www.internalfb.com/code/fbsource/[6a3ea67be1490a510f47d57be2e049253c81bdae]/xplat/js/react-native-github/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js?lines=137%2C139). However, we have [additional calls](https://www.internalfb.com/code/fbsource/[6a3ea67be1490a510f47d57be2e049253c81bdae]/xplat/js/react-native-github/packages/react-native/Libraries/Animated/useAnimatedProps.js?lines=256%2C320) to `flushQueue` in the useAnimatedProps lifecycle functions. They seem redundant, and animations seem to work fine without them. Let's get rid of them. Differential Revision: D62103788 --- .../Libraries/Animated/useAnimatedProps.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/react-native/Libraries/Animated/useAnimatedProps.js b/packages/react-native/Libraries/Animated/useAnimatedProps.js index e4dd4f7791f0ec..23ad6ac583d166 100644 --- a/packages/react-native/Libraries/Animated/useAnimatedProps.js +++ b/packages/react-native/Libraries/Animated/useAnimatedProps.js @@ -268,10 +268,6 @@ function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void { const isUnmountingRef = useRef(false); useEffect(() => { - // It is ok for multiple components to call `flushQueue` because it noops - // if the queue is empty. When multiple animated components are mounted at - // the same time. Only first component flushes the queue and the others will noop. - NativeAnimatedHelper.API.flushQueue(); let drivenAnimationEndedListener: ?EventSubscription = null; if (node.__isNative) { drivenAnimationEndedListener = @@ -326,13 +322,6 @@ function useAnimatedPropsLifecycle_insertionEffects(node: AnimatedProps): void { const prevNodeRef = useRef(null); const isUnmountingRef = useRef(false); - useEffect(() => { - // It is ok for multiple components to call `flushQueue` because it noops - // if the queue is empty. When multiple animated components are mounted at - // the same time. Only first component flushes the queue and the others will noop. - NativeAnimatedHelper.API.flushQueue(); - }); - useInsertionEffect(() => { isUnmountingRef.current = false; return () => {