From b5f1b3dffc9c1bc4cf91a96528fc17a4942458b6 Mon Sep 17 00:00:00 2001 From: Genki Kondo Date: Thu, 23 Jun 2022 08:14:03 -0700 Subject: [PATCH] Add check for native animated node existing before starting animation Summary: We need to check that the animated node exists prior to executing the animation. The native animated node lifecycle is not synced with Fabric and nodes are frequently destroyed and re-created on rerenders. Therefore, there is a possibility that the the animated node does not exist when the native event is dispatched, in particular with native call batching. Changelog: [Internal] - Make NativeAnimatedNodesManager.getNodeById public Reviewed By: JoshuaGross Differential Revision: D37323138 fbshipit-source-id: ed0567871b4189c454b6b3145b853ecdfe844840 --- .../facebook/react/animated/NativeAnimatedNodesManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java index 83307b52c1e..9a6953529b4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java @@ -100,8 +100,8 @@ public class NativeAnimatedNodesManager implements EventDispatcherListener { } } - /*package*/ @Nullable - AnimatedNode getNodeById(int id) { + @Nullable + public AnimatedNode getNodeById(int id) { return mAnimatedNodes.get(id); }