Skip to content

Commit

Permalink
Animated: Create enableAnimatedAllowlist Feature Flag
Browse files Browse the repository at this point in the history
Summary:
Creates a feature flag for enabling the `Animated` code paths utilizing the new allowlist features. This enables us to validate the impact on product performance and developer experience before fully rolling it out.

Changelog:
[Internal]

Differential Revision: D62405286
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 10, 2024
1 parent 8dabed6 commit d5a72eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/react-native/Libraries/Animated/useAnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
const onUpdateRef = useRef<?() => void>(null);
const timerRef = useRef<TimeoutID | null>(null);

const allowlistIfEnabled = ReactNativeFeatureFlags.enableAnimatedAllowlist()
? allowlist
: null;

// TODO: Only invalidate `node` if animated props or `style` change. In the
// previous implementation, we permitted `style` to override props with the
// same name property name as styles, so we can probably continue doing that.
// The ordering of other props *should* not matter.
const node = useMemo(
() => new AnimatedProps(props, () => onUpdateRef.current?.(), allowlist),
[allowlist, props],
() =>
new AnimatedProps(
props,
() => onUpdateRef.current?.(),
allowlistIfEnabled,
),
[allowlistIfEnabled, props],
);
const useNativePropsInFabric =
ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ const definitions: FeatureFlagDefinitions = {
description:
'Enables access to the host tree in Fabric using DOM-compatible APIs.',
},
enableAnimatedAllowlist: {
defaultValue: false,
description: 'Enables Animated to skip non-allowlisted props and styles.',
},
enableOptimisedVirtualizedCells: {
defaultValue: false,
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<0bff47ec5af8ed96d8b2abe351f318f1>>
* @generated SignedSource<<ea4c7d3691081d2eb90a4041defd7d44>>
* @flow strict-local
*/

Expand All @@ -30,6 +30,7 @@ export type ReactNativeFeatureFlagsJsOnly = {
animatedShouldDebounceQueueFlush: Getter<boolean>,
animatedShouldUseSingleOp: Getter<boolean>,
enableAccessToHostTreeInFabric: Getter<boolean>,
enableAnimatedAllowlist: Getter<boolean>,
enableOptimisedVirtualizedCells: Getter<boolean>,
isLayoutAnimationEnabled: Getter<boolean>,
shouldSkipStateUpdatesForLoopingAnimations: Getter<boolean>,
Expand Down Expand Up @@ -115,6 +116,11 @@ export const animatedShouldUseSingleOp: Getter<boolean> = createJavaScriptFlagGe
*/
export const enableAccessToHostTreeInFabric: Getter<boolean> = createJavaScriptFlagGetter('enableAccessToHostTreeInFabric', false);

/**
* Enables Animated to skip non-allowlisted props and styles.
*/
export const enableAnimatedAllowlist: Getter<boolean> = createJavaScriptFlagGetter('enableAnimatedAllowlist', false);

/**
* Removing unnecessary rerenders Virtualized cells after any rerenders of Virualized list. Works with strict=true option
*/
Expand Down

0 comments on commit d5a72eb

Please sign in to comment.