From 334da89b3d4987416212a06c8b9b4bb292e46d76 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 23 Mar 2021 14:34:57 -0700 Subject: [PATCH] LayoutAnimation: don't call non-Fabric configurNext if Fabric is installed Summary: If Fabric is "installed"/enabled in the JS VM, only send LayoutAnimations configureNext to Fabric. This will have no impact unless your app is running Fabric and non-Fabric side-by-side. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D27274016 fbshipit-source-id: 5d709e23968c2b65cc79d5611170fb70a9578953 --- Libraries/LayoutAnimation/LayoutAnimation.js | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 9ff9f7fb1e6..efb12afa5dc 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -62,15 +62,6 @@ function configureNext( (config.duration ?? 0) + 17 /* one frame + 1ms */, ); - if (UIManager?.configureNextLayoutAnimation) { - UIManager.configureNextLayoutAnimation( - config, - onAnimationComplete ?? function() {}, - onAnimationDidFail ?? - function() {} /* this should never be called in Non-Fabric */, - ); - } - // In Fabric, LayoutAnimations are unconditionally enabled for Android, and // conditionally enabled on iOS (pending fully shipping; this is a temporary state). const FabricUIManager: FabricUIManagerSpec = global?.nativeFabricUIManager; @@ -81,6 +72,19 @@ function configureNext( onAnimationDidFail ?? function() {} /* this will only be called if configuration parsing fails */, ); + return; + } + + // This will only run if Fabric is *not* installed. + // If you have Fabric + non-Fabric running in the same VM, non-Fabric LayoutAnimations + // will not work. + if (UIManager?.configureNextLayoutAnimation) { + UIManager.configureNextLayoutAnimation( + config, + onAnimationComplete ?? function() {}, + onAnimationDidFail ?? + function() {} /* this should never be called in Non-Fabric */, + ); } }