diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index c79fc75df5b4..ed1c62d97394 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,12 @@ void UIManagerBinding::createAndInstallIfNeeded( auto object = jsi::Object::createFromHostObject(runtime, uiManagerBinding); runtime.global().setProperty( runtime, uiManagerModuleName, std::move(object)); + + // Tag this thread (the JS runtime thread) as the one allowed to propagate + // runtime shadow-node reference updates during Fabric commit. The flag is + // thread_local, so it must be set on the JS thread; installing the binding + // is guaranteed to run there and to happen before any JS-driven commit. + ShadowNode::setUseRuntimeShadowNodeReferenceUpdateOnThread(true); } } diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 4d12c90edfb3..e6b8f129d5f4 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -98,7 +97,6 @@ ReactInstance::ReactInstance( jsi::Runtime& jsiRuntime = runtime->getRuntime(); TraceSection s("ReactInstance::_runtimeExecutor[Callback]"); try { - ShadowNode::setUseRuntimeShadowNodeReferenceUpdateOnThread(true); callback(jsiRuntime); } catch (jsi::JSError& originalError) { jsErrorHandler->handleError(jsiRuntime, originalError, true);