Skip to content

Commit

Permalink
Use a legacy native module binding that always returns null in bridge…
Browse files Browse the repository at this point in the history
…less mode (microsoft#13905)

* Use a legacy native module binding that always returns null in bridgeless mode

* Change files

* format
  • Loading branch information
acoates-ms committed Oct 15, 2024
1 parent 1a83ce8 commit 2be516c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use a legacy native module binding that always returns null in bridgeless mode",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
10 changes: 9 additions & 1 deletion vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,16 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
return turboModuleManager->getModule(name);
};

// Use a legacy native module binding that always returns null
// This means that calls to NativeModules.XXX will always return null, rather than crashing on access
auto legacyNativeModuleBinding =
[](const std::string & /*name*/) -> std::shared_ptr<facebook::react::TurboModule> { return nullptr; };

facebook::react::TurboModuleBinding::install(
runtime, std::function(binding), nullptr, m_options.TurboModuleProvider->LongLivedObjectCollection());
runtime,
std::function(binding),
std::function(legacyNativeModuleBinding),
m_options.TurboModuleProvider->LongLivedObjectCollection());

auto componentDescriptorRegistry =
Microsoft::ReactNative::WindowsComponentDescriptorRegistry::FromProperties(
Expand Down

0 comments on commit 2be516c

Please sign in to comment.