Skip to content

Commit da7c91c

Browse files
committed
accommodate for breaking changes in 0.70
1 parent ce4d31d commit da7c91c

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

android/app/src/main/jni/TurboModuleManagerDelegate.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ using facebook::react::CallInvoker;
77
using facebook::react::JavaTurboModule;
88
using facebook::react::TurboModule;
99
using ReactTestApp::TurboModuleManagerDelegate;
10+
using ReactTestApp::TurboModuleManagerDelegate::SharedCallInvoker;
11+
using ReactTestApp::TurboModuleManagerDelegate::StringRef;
1012

1113
void TurboModuleManagerDelegate::registerNatives()
1214
{
@@ -16,14 +18,14 @@ void TurboModuleManagerDelegate::registerNatives()
1618
});
1719
}
1820

19-
std::shared_ptr<TurboModule>
20-
TurboModuleManagerDelegate::getTurboModule(const std::string, const std::shared_ptr<CallInvoker>)
21+
std::shared_ptr<TurboModule> TurboModuleManagerDelegate::getTurboModule(const StringRef,
22+
const SharedCallInvoker)
2123
{
2224
return nullptr;
2325
}
2426

2527
std::shared_ptr<TurboModule> TurboModuleManagerDelegate::getTurboModule(
26-
const std::string name, const JavaTurboModule::InitParams &params)
28+
const StringRef name, const JavaTurboModule::InitParams &params)
2729
{
2830
// Try autolinked module providers first
2931
auto rncli_module = rncli_ModuleProvider(name, params);
@@ -41,7 +43,7 @@ TurboModuleManagerDelegate::initHybrid(
4143
return makeCxxInstance();
4244
}
4345

44-
bool TurboModuleManagerDelegate::canCreateTurboModule(std::string name)
46+
bool TurboModuleManagerDelegate::canCreateTurboModule(const StringRef name)
4547
{
4648
return getTurboModule(name, nullptr) != nullptr ||
4749
getTurboModule(name, {.moduleName = name}) != nullptr;

android/app/src/main/jni/TurboModuleManagerDelegate.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@ namespace ReactTestApp
1414
: public facebook::jni::HybridClass<TurboModuleManagerDelegate,
1515
facebook::react::TurboModuleManagerDelegate>
1616
{
17+
// Signatures changed in 0.70 to avoid unnecessary string copies; see
18+
// https://github.com/facebook/react-native/commit/3337add547c60b84816ef5dad82f4ead2e8742ef
19+
#if __has_include(<ReactCommon/CompositeTurboModuleManagerDelegate.h>)
20+
using SharedCallInvoker = std::shared_ptr<facebook::react::CallInvoker> &;
21+
using StringRef = std::string &;
22+
#else
23+
using SharedCallInvoker = std::shared_ptr<facebook::react::CallInvoker>;
24+
using StringRef = std::string;
25+
#endif
26+
1727
public:
1828
static constexpr auto kJavaDescriptor =
1929
"Lcom/microsoft/reacttestapp/turbomodule/TurboModuleManagerDelegate;";
2030

2131
static void registerNatives();
2232

2333
std::shared_ptr<facebook::react::TurboModule>
24-
getTurboModule(const std::string name, //
25-
const std::shared_ptr<facebook::react::CallInvoker> jsInvoker) override;
34+
getTurboModule(const StringRef name, const SharedCallInvoker jsInvoker) override;
2635

2736
std::shared_ptr<facebook::react::TurboModule>
28-
getTurboModule(const std::string name, //
37+
getTurboModule(const StringRef name, //
2938
const facebook::react::JavaTurboModule::InitParams &params) override;
3039

3140
private:
@@ -36,7 +45,7 @@ namespace ReactTestApp
3645
* Test-only method. Allows user to verify whether a TurboModule can be
3746
* created by instances of this class.
3847
*/
39-
bool canCreateTurboModule(std::string name);
48+
bool canCreateTurboModule(const StringRef name);
4049
};
4150
} // namespace ReactTestApp
4251

0 commit comments

Comments
 (0)