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
This commit is contained in:
Genki Kondo authored and Facebook GitHub Bot committed 2022-06-23 08:14:03 -07:00
1 parent a0d597dbca
commit b5f1b3dffc
1 file changed
+2 -2
@@ -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);
}