diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 484de75256f..b6092f2e388 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -525,7 +525,8 @@ void NativeReanimatedModule::performOperations() { ReanimatedCommitMarker commitMarker; shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const &oldRootShadowNode) + -> RootShadowNode::Unshared { auto rootNode = oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{}); @@ -535,6 +536,15 @@ void NativeReanimatedModule::performOperations() { const ShadowNodeFamily &family = shadowNode->getFamily(); react_native_assert(family.getSurfaceId() == surfaceId_); +#if REACT_NATIVE_MINOR_VERSION >= 73 + // Fix for catching nullptr returned from commit hook was introduced + // in 0.72.4 but we have only check for minor version of React + // Native so enable that optimization in React Native >= 0.73 + if (propsRegistry_->shouldReanimatedSkipCommit()) { + return nullptr; + } +#endif + auto newRootNode = shadowTreeCloner.cloneWithNewProps( rootNode, family, RawProps(rt, *props)); @@ -551,7 +561,11 @@ void NativeReanimatedModule::performOperations() { return newRoot; }, - {/* default commit options */}); + {/* .enableStateReconciliation = */ false, + /* .mountSynchronously = */ true, + /* .shouldYield = */ [this]() { + return propsRegistry_->shouldReanimatedSkipCommit(); + }}); }); }