MCPcopy Create free account
hub / github.com/expo/expo / requireNativeModule

Function requireNativeModule

packages/expo-modules-core/src/requireNativeModule.web.ts:1–11  ·  view source on GitHub ↗
(moduleName: string)

Source from the content-addressed store, hash-verified

1export function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {
2 const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);
3 if (nativeModule != null) {
4 return nativeModule;
5 }
6 if (typeof window === 'undefined') {
7 // For SSR, we expect not to have native modules available, but to avoid crashing from SSR resolutions, we return an empty object.
8 return {} as ModuleType;
9 }
10 throw new Error(`Cannot find native module '${moduleName}'`);
11}
12
13export function requireOptionalNativeModule<ModuleType = any>(
14 moduleName: string

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…