From 185a6130ddc566ef67d04f83721f41d13651dbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 30 Mar 2026 07:25:20 -0700 Subject: [PATCH] Replace FIXME comment with explanation for JS safety in MutationObserver (#56271) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56271 Replace the FIXME(T157129303) comment in NativeMutationObserver with a clarifying comment explaining why it is safe to call into JS at that point: we only check mutations synchronously when committing from React, so we are already in a JS task. Changelog: [Internal] Reviewed By: javache Differential Revision: D98714071 fbshipit-source-id: 90738e9ec6e2215dff331a3b714373bf52f4b24b --- .../nativemodule/mutationobserver/NativeMutationObserver.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.cpp b/packages/react-native/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.cpp index 1dab573fafc..98ff3f2e291 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.cpp @@ -116,8 +116,9 @@ void NativeMutationObserver::onMutations(std::vector& records) { pendingRecords_.emplace_back( NativeMutationRecord{ record.mutationObserverId, - // FIXME(T157129303) Instead of assuming we can call into JS from - // here, we should use an API that explicitly indicates it. + // It's safe to call into JS here because we only check mutations + // synchronously when committing from React (so we're in a JS + // task already). getPublicInstanceFromShadowNode(*record.targetShadowNode), getPublicInstancesFromShadowNodes(record.addedShadowNodes), getPublicInstancesFromShadowNodes(record.removedShadowNodes)});