How to migrate to TurboModules
Modules running as TurboModules will be available in the JS from
TurboModuleRegistry.get('<modulename>') instead of
Starting in version 0.71, JS/TS spec files can codegen C++ spec files that can verify that the native implementation matches the definition in JS. In addition modules can now be run as TurboModules instead of as a Native Module simply by using adding an additional parameter to your call to
Alternatively if you are registering modules more manually by calling
IReactPackageBuilder.AddModule, you can call
Additional differences running as Native Module vs TurboModule
After creating a spec in JS, you should see JS type errors showing that constants should be accessed using
MyModule.getConstants().myconst instead of
MyModule.myconst. If you fail to update you accesses of
myconst the field will continue to work when the module is running as a Native Module, since Native Modules promote all the constants to fields on the module. This behavior does not happen with TurboModules, so the
myconst field will be undefined. Calls using
getConstants().myconst will work both for Native Modules and TurboModules.
Web Debugging Behavior
TurboModules cannot run when using Remote Debugging / Web Debugging. React-Native-Windows will attempt to run a TurboModule as a native module when running in that mode, but if the module is using JSI directly, that fallback may not work.