Skip to content

Commit 4def40e

Browse files
cortinicohuntie
authored andcommitted
Hook the default-app-setup OnLoad.cpp file with the cxxModuleProvider from RNCLI (#43049)
Summary: Pull Request resolved: #43049 This connects the OnLoad.cpp file used by OSS apps with the `rncli_cxxModuleProvider`. This method is created by the CLI and takes care of querying all the TM CXX Modules discovered and returning them. This PR is currently waiting on react-native-community/cli#2296 Changelog: [Internal] [Changed] - Hook the default-app-setup OnLoad.cpp file with the cxxModuleProvider from RNCLI Reviewed By: cipolleschi Differential Revision: D53812109 fbshipit-source-id: 47bc0ea699516993070cfa0127de97853acf8890
1 parent 341fbe5 commit 4def40e

File tree

1 file changed

+10
-2
lines changed
  • packages/react-native/ReactAndroid/cmake-utils/default-app-setup

1 file changed

+10
-2
lines changed

packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ void registerComponents(
6262
std::shared_ptr<TurboModule> cxxModuleProvider(
6363
const std::string& name,
6464
const std::shared_ptr<CallInvoker>& jsInvoker) {
65-
// Not implemented yet: provide pure-C++ NativeModules here.
66-
return nullptr;
65+
// Here you can provide your CXX Turbo Modules coming from
66+
// either your application or from external libraries. The approach to follow
67+
// is similar to the following (for a module called `NativeCxxModuleExample`):
68+
//
69+
// if (name == NativeCxxModuleExample::kModuleName) {
70+
// return std::make_shared<NativeCxxModuleExample>(jsInvoker);
71+
// }
72+
73+
// And we fallback to the CXX module providers autolinked by RN CLI
74+
return rncli_cxxModuleProvider(name, jsInvoker);
6775
}
6876

6977
std::shared_ptr<TurboModule> javaModuleProvider(

0 commit comments

Comments
 (0)