Skip to content

Commit 1faa665

Browse files
generatedunixname1608173377072046meta-codesync[bot]
authored andcommitted
Guard against OTA mismatch in NativeAnimatedHelper queue (#56802)
Summary: Pull Request resolved: #56802 When MobileConfig flags (`cxxNativeAnimatedEnabled` and `useSharedAnimatedBackend`) are enabled server-side, `connectAnimatedNodeToShadowNodeFamily` is added to the method names list in `createNativeOperations()`. However, MobileConfig values and what is available in the AnimatedModule on the client can mismatch due to OTA updates — the JS bundle may have the flag enabled while the native module on the device does not yet implement the method. In this case, `nullthrows(NativeAnimatedModule)[methodName]` returns `undefined`, which gets queued as `() => undefined(...args)` and throws TypeError when the queue is flushed. This fix adds a runtime check that `NativeAnimatedModule?.connectAnimatedNodeToShadowNodeFamily != null` before including the method in the list, preventing the mismatch from surfacing. The specific guard at the registration site is sufficient — if the method is not available on the native module, it will never be registered, so the general null guard in the method wrapper is unnecessary. Fixes T270861607. Changelog: [Internal] Reviewed By: zeyap Differential Revision: D104775294 fbshipit-source-id: ece86a3ab37792bf9624985eebfc53059af61677
1 parent 2991a97 commit 1faa665

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/react-native/src/private/animated/NativeAnimatedHelper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ function createNativeOperations(): NonNullable<typeof NativeAnimatedModule> {
9898
if (
9999
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
100100
//eslint-disable-next-line
101-
ReactNativeFeatureFlags.useSharedAnimatedBackend()
101+
ReactNativeFeatureFlags.useSharedAnimatedBackend() &&
102+
NativeAnimatedModule?.connectAnimatedNodeToShadowNodeFamily != null
102103
) {
103104
methodNames.push('connectAnimatedNodeToShadowNodeFamily');
104105
}

0 commit comments

Comments
 (0)