Skip to content

Commit fbf196d

Browse files
philIipfacebook-github-bot
authored andcommitted
make getModuleClassFromName: required (#36968)
Summary: Pull Request resolved: #36968 Changelog: [iOS][Breaking] we should be using `optional` never. this will be a breaking change if you have any class that conform to `RCTTurboModuleManagerDelegate` #saynotoruntimechecks Reviewed By: cipolleschi Differential Revision: D45022003 fbshipit-source-id: d1b3cf72bae82070704f20de4558949189da462a
1 parent fce5aa7 commit fbf196d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ RCT_EXTERN void RCTTurboModuleSetBindingMode(facebook::react::TurboModuleBinding
1919

2020
@protocol RCTTurboModuleManagerDelegate <NSObject>
2121

22-
@optional
23-
2422
/**
25-
* Given a module name, return its actual class. If not provided, basic ObjC class lookup is performed.
23+
* Given a module name, return its actual class. If nil is returned, basic ObjC class lookup is performed.
2624
*/
2725
- (Class)getModuleClassFromName:(const char *)name;
2826

27+
@optional
28+
2929
/**
3030
* Given a module class, provide an instance for it. If not provided, default initializer is used.
3131
*/

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,11 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName
388388
/**
389389
* Step 2a: Resolve platform-specific class.
390390
*/
391-
392-
if ([_delegate respondsToSelector:@selector(getModuleClassFromName:)]) {
393-
if (RCTTurboModuleManagerDelegateLockingDisabled()) {
394-
moduleClass = [_delegate getModuleClassFromName:moduleName];
395-
} else {
396-
std::lock_guard<std::mutex> delegateGuard(_turboModuleManagerDelegateMutex);
397-
moduleClass = [_delegate getModuleClassFromName:moduleName];
398-
}
391+
if (RCTTurboModuleManagerDelegateLockingDisabled()) {
392+
moduleClass = [_delegate getModuleClassFromName:moduleName];
393+
} else {
394+
std::lock_guard<std::mutex> delegateGuard(_turboModuleManagerDelegateMutex);
395+
moduleClass = [_delegate getModuleClassFromName:moduleName];
399396
}
400397

401398
if (!moduleClass) {

0 commit comments

Comments
 (0)