From 05b4570d3ff1004e995ff618b10ed115799a5fbb Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 18 Feb 2022 17:35:53 -0800 Subject: [PATCH] Refactor LayoutAnimation to use ReactNativeFeatureFlags Summary: This diff refactors LayoutAnimation to use ReactNativeFeatureFlags.ENABLE_LAYOUT_ANIMATION to enable / disable this feature changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D34349648 fbshipit-source-id: 90d1db6560867e44eeffbf03e5a84edadcdd55f9 --- Libraries/LayoutAnimation/LayoutAnimation.js | 6 ++++-- Libraries/ReactNative/ReactNativeFeatureFlags.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 2001729e004..561ef2f71d9 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -19,6 +19,7 @@ import type { } from '../Renderer/shims/ReactNativeTypes'; import Platform from '../Utilities/Platform'; +import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags'; // Reexport type export type LayoutAnimationConfig = LayoutAnimationConfig_; @@ -26,10 +27,11 @@ export type LayoutAnimationConfig = LayoutAnimationConfig_; type OnAnimationDidEndCallback = () => void; type OnAnimationDidFailCallback = () => void; -let isLayoutAnimationEnabled: boolean = true; +let isLayoutAnimationEnabled: boolean = + ReactNativeFeatureFlags.isLayoutAnimationEnabled(); function setEnabled(value: boolean) { - isLayoutAnimationEnabled = value; + isLayoutAnimationEnabled = isLayoutAnimationEnabled; } /** diff --git a/Libraries/ReactNative/ReactNativeFeatureFlags.js b/Libraries/ReactNative/ReactNativeFeatureFlags.js index 89f4334d23c..90a9eee5180 100644 --- a/Libraries/ReactNative/ReactNativeFeatureFlags.js +++ b/Libraries/ReactNative/ReactNativeFeatureFlags.js @@ -11,6 +11,10 @@ 'use strict'; export type FeatureFlags = {| + /** + * Function used to enable / disabled Layout Animations in React Native. + * Default value = true. + */ isLayoutAnimationEnabled: () => boolean, |};