From b648971a9772f01863a732f960d2921c8c3f3063 Mon Sep 17 00:00:00 2001 From: Dmitry Rykun <dmitryrykun@meta.com> Date: Wed, 4 Sep 2024 08:45:52 -0700 Subject: [PATCH] Delete redundant calls to flushQueue Summary: 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 | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/react-native/Libraries/Animated/useAnimatedProps.js b/packages/react-native/Libraries/Animated/useAnimatedProps.js index 0ed02fb7b6632b..e4682d333fb735 100644 --- a/packages/react-native/Libraries/Animated/useAnimatedProps.js +++ b/packages/react-native/Libraries/Animated/useAnimatedProps.js @@ -250,11 +250,6 @@ function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void { const userDrivenAnimationEndedListener = useRef<?EventSubscription>(null); 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(); - if (node.__isNative) { userDrivenAnimationEndedListener.current = NativeAnimatedHelper.nativeEventEmitter.addListener( @@ -313,13 +308,6 @@ function useAnimatedPropsLifecycle_passiveEffects(node: AnimatedProps): void { const prevNodeRef = useRef<?AnimatedProps>(null); const isUnmountingRef = useRef<boolean>(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(); - }); - useEffect(() => { isUnmountingRef.current = false; return () => {