Files
react-native/packages
Ramanpreet Nara af5c2d2c75 Only create TurboModules, if they're registered (#37032)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37032

Before, calling into global.turboModuleProxy would kickstart the  module creation algorithm, **even if the module wasn't registered.**

Now, if the module isn't registered, TurboModuleManager will just early return null.

NOTE: When an unregistered module is requested from Java via TurboModuleManager.getModule(moduleName), the module algorithm will **still** run.

This fixes a bug:
- global.**native**ModuleProxy will no longer kickstart **turbo** module creation.
- global.**turbo**ModuleProxy will no longer kickstart **legacy** module creation.

NOTE: This **might** improve fb4a performance **a bit**: The TurboModule creation algorithm is *probably* expensive to run. 44 NativeModules are loaded at startup by Fb4a; 8 of them aren't registered with the app: [pastry](https://www.internalfb.com/phabricator/paste/view/P701125588?lines=2%2C4%2C5%2C7%2C9%2C16%2C18%2C24). Those 8 NativeModule creates will now shortcircuit to null faster.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D45195578

fbshipit-source-id: cb09bdc059b3651b02447b7c2e37ef3f4ca2f92b
2023-04-21 16:37:04 -07:00
..
2023-04-20 16:26:38 -07:00