mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3f38186b78
Summary: We're making the getTurboModule: method required for all classes that conform to RCTTurboModule. Many of our ObjC-only and Cxx NativeModules don't implement this method. This diff implements a getTurboModule: method on all those modules that returns nullptr. **Question:** Why is it fine to make ObjC-only NativeModules return nullptr from their getTurboModule: method? - Because they're only accessed from ObjC, and should appear as null on the JavaScript side. Longer term, these NativeModules will also go away. **Question:** Why is it fine to make Cxx NativeModules return nullptr from getTurboModule: method? - Because after D27316872, the TurboModuleManager checks if the module is a CxxModule first. If it is, we do an early return, and never call the module's getTurboModule: method. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D27316871 fbshipit-source-id: bc693f2927ab3b0de24e6e9e7699390ec0f7d729
55 lines
1.2 KiB
Plaintext
55 lines
1.2 KiB
Plaintext
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTSampleTurboCxxModule.h"
|
|
|
|
#import <ReactCommon/SampleTurboCxxModule.h>
|
|
#import <cxxreact/CxxModule.h>
|
|
#import "SampleTurboCxxModuleLegacyImpl.h"
|
|
|
|
using namespace facebook;
|
|
|
|
// ObjC++ wrapper.
|
|
@implementation RCTSampleTurboCxxModule_v1
|
|
|
|
RCT_EXPORT_MODULE();
|
|
|
|
- (std::shared_ptr<react::TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<react::CallInvoker>)jsInvoker
|
|
{
|
|
return std::make_shared<react::SampleTurboCxxModule>(jsInvoker);
|
|
}
|
|
|
|
- (std::unique_ptr<xplat::module::CxxModule>)createModule
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation RCTSampleTurboCxxModule_v2
|
|
|
|
RCT_EXPORT_MODULE();
|
|
|
|
- (std::unique_ptr<xplat::module::CxxModule>)createModule
|
|
{
|
|
return std::make_unique<react::SampleTurboCxxModuleLegacyImpl>();
|
|
}
|
|
|
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
@end
|