Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/react-native/src/NativeScriptNativeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ export interface Spec extends TurboModule {
readonly __writeTestMarker: (content: string) => boolean;
}

export default TurboModuleRegistry.getEnforcing<Spec>('NativeScriptNativeApi');
function loadNativeApi(): Spec {
const nativeApi = TurboModuleRegistry.get<Spec>('NativeScriptNativeApi');
if (nativeApi == null) {
throw new Error(
"@nativescript/react-native: the native module 'NativeScriptNativeApi' is not in this app binary. " +
'The package contains native code, so it cannot run in Expo Go: use a development build ' +
'(npx expo run:ios / npx expo run:android, or EAS Build). ' +
'If the package was added after the app was built, rebuild the app.',
);
}
return nativeApi;
}

export default loadNativeApi();
Loading