Don't lookup TurboModules post-invalidation

Summary:
During cleanup, RCTNativeAnimatedModule [requires the RCTEventDispatcher](https://fburl.com/diffusion/0bnln893) to remove itself from the dispatcher a dispatch observer.

When the bridge is invalidated, if RCTEventDispatcher is has been cleaned up by then, we don't warn when this lookup fails: https://fburl.com/diffusion/rfioe5ay. This diff replicates that behaviour in the TurboModule infra.

Notes:
- In the legacy NativeModule infra, we can still query NativeModules post invalidation - we just won't create them. In the TurboModule infra, all requests for TurboModules from the TurboModuleManager start returning nil. Therefore, I simply did an early return inside TurboModuleManager moduleForName in the case that we're already invalidated. In addition to not displaying the warning, we just don't request/create the TurboModule in the first place.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25560228

fbshipit-source-id: 102dcc147bab6121daacdb39890bad48c0e60894
This commit is contained in:
Ramanpreet Nara
2020-12-15 11:20:28 -08:00
committed by Facebook GitHub Bot
parent 42dde12aac
commit 0da02ab1ca
@@ -761,6 +761,12 @@ static Class getFallbackClassFromName(const char *name)
- (id)moduleForName:(const char *)moduleName warnOnLookupFailure:(BOOL)warnOnLookupFailure
{
// When the bridge is invalidating, TurboModules will be nil.
// Therefore, don't (1) do the lookup, and (2) warn on lookup.
if (_invalidating) {
return nil;
}
id<RCTTurboModule> module = [self provideRCTTurboModule:moduleName];
if (warnOnLookupFailure && !module) {