fix(lib/modules/native): getNativeModule should fallback to legacy if turbo module doesn't exist

This commit is contained in:
PalmDevs 2025-08-13 01:12:36 +07:00
parent 3563daed39
commit e0c2ca7d6c
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -10,11 +10,11 @@ const turboModuleProxy = globalThis.__turboModuleProxy
* @param name The name of the native module to get.
*/
export function getNativeModule<T>(name: string): T | null {
const module = turboModuleProxy
? // Non-bridgeless with TurboModules
turboModuleProxy(name)
: // Bridgeless & legacy modules
nativeModuleProxy[name]
const module =
// Non-bridgeless with TurboModules
turboModuleProxy?.(name) ??
// Bridgeless & legacy modules
nativeModuleProxy[name]
if (module) return module as T