Remove assertion on TurboModule existence

Summary:
It's okay for TurboModules to not exist. Therefore, `__turboModuleProvider(moduleName)` should return null if `moduleName` doesn't refer to an actual TurboModule. The current implementation assumes that the TurboModule must exist, and therefore, it crashes the app when it doesn't (assertion error).

This change is important because it helps us land D13887962. When we switch `I18nResources` to `TurboModuleRegistry` in D13887962, on Wilde, it won't be found in `NativeModules`. Therefore, we'll try to lookup this module in `__turboModuleProvider`, and this will crash the app. It seems like `I18nResources` is a Java-only module?

Reviewed By: fkgozali

Differential Revision: D13924589

fbshipit-source-id: 7ac7b1873e06852e5aafcaaef5c24cbc548ee444
This commit is contained in:
Ramanpreet Nara 2019-02-04 11:32:31 -08:00 committed by Facebook Github Bot
parent e1451caddd
commit aa39cb6d9f
1 changed files with 3 additions and 2 deletions

View File

@ -114,8 +114,9 @@ static Class getFallbackClassFromName(const char *name) {
// If we request that a TurboModule be created, its respective ObjC class must exist
// If the class doesn't exist, then provideRCTTurboModule returns nil
// Therefore, module cannot be nil.
assert(module);
if (!module) {
return nullptr;
}
Class moduleClass = [module class];