mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
fix(iOS): provide useful error message about dependency provider (#49843)
Summary: Currently, when integrating into a native app using ReactNativeFactory, when we forget to set `dependencyProvider` we get a random crash exception instructing us (depending on native modules in our app) about an unrecognized selector:  After this change we get a proper error informing us that we for got to set dependencyProvider:  ## Changelog: [IOS] [ADDED] - Useful error message about setting dependency provider Pull Request resolved: https://github.com/facebook/react-native/pull/49843 Test Plan: CI Green Reviewed By: cortinico Differential Revision: D70631515 Pulled By: cipolleschi fbshipit-source-id: d99c8fa12fdb0624a01fe16c50fe0f2d10554f94
This commit is contained in:
1 parent
22cd3b1023
commit
e1464c0975
1 file changed
+7
@@ -196,6 +196,13 @@ using namespace facebook::react;
|
||||
|
||||
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
||||
{
|
||||
#if USE_OSS_CODEGEN
|
||||
if (self.delegate.dependencyProvider == nil) {
|
||||
[NSException raise:@"ReactNativeFactoryDelegate dependencyProvider is nil"
|
||||
format:@"Delegate must provide a valid dependencyProvider"];
|
||||
}
|
||||
#endif
|
||||
|
||||
return RCTAppSetupDefaultModuleFromClass(moduleClass, self.delegate.dependencyProvider);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user