diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index ea24e5c8682..e0d9779d6b2 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -242,7 +243,17 @@ void ReactInstance::loadScript( ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); } - runtime.evaluateJavaScript(buffer, sourceURL); + // Check if the shermes unit is avaliable. + auto* shUnitAPI = jsi::castInterface(&runtime); + auto* shUnitCreator = shUnitAPI ? shUnitAPI->getSHUnitCreator() : nullptr; + if (shUnitCreator) { + LOG(WARNING) << "ReactInstance: evaluateSHUnit"; + auto* hermesAPI = jsi::castInterface(&runtime); + hermesAPI->evaluateSHUnit(shUnitCreator); + } else { + LOG(WARNING) << "ReactInstance: evaluateJavaScript() with JS bundle"; + runtime.evaluateJavaScript(buffer, sourceURL); + } /** * TODO(T183610671): We need a safe/reliable way to enable the js