diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.cpp index 4796310bca7277..a0c76fcbcb063a 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.cpp @@ -29,7 +29,8 @@ CompositeTurboModuleManagerDelegate::getTurboModule( const std::string &moduleName, const std::shared_ptr &jsInvoker) { for (auto delegate : mDelegates_) { - if (auto turboModule = delegate->getTurboModule(moduleName, jsInvoker)) { + if (auto turboModule = + delegate->cthis()->getTurboModule(moduleName, jsInvoker)) { return turboModule; } } @@ -41,7 +42,8 @@ CompositeTurboModuleManagerDelegate::getTurboModule( const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { for (auto delegate : mDelegates_) { - if (auto turboModule = delegate->getTurboModule(moduleName, params)) { + if (auto turboModule = + delegate->cthis()->getTurboModule(moduleName, params)) { return turboModule; } } @@ -49,9 +51,8 @@ CompositeTurboModuleManagerDelegate::getTurboModule( } void CompositeTurboModuleManagerDelegate::addTurboModuleManagerDelegate( - jni::alias_ref - turboModuleManagerDelegate) { - mDelegates_.insert(turboModuleManagerDelegate->cthis()); + jni::alias_ref delegate) { + mDelegates_.push_back(jni::make_global(delegate)); } } // namespace facebook::react diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.h b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.h index 46aece570b1a6d..9f4fdb6c42cfa8 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/CompositeTurboModuleManagerDelegate.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace facebook::react { @@ -30,6 +30,7 @@ class CompositeTurboModuleManagerDelegate std::shared_ptr getTurboModule( const std::string &moduleName, const std::shared_ptr &jsInvoker) override; + std::shared_ptr getTurboModule( const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) override; @@ -37,11 +38,11 @@ class CompositeTurboModuleManagerDelegate private: friend HybridBase; using HybridBase::HybridBase; - std::unordered_set mDelegates_; + std::vector> + mDelegates_; void addTurboModuleManagerDelegate( - jni::alias_ref - turboModuleManagerDelegate); + jni::alias_ref delegate); }; } // namespace facebook::react