-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
In React Native, if a function throws an error, the error is not passed, but the function rejects NativeMethodError in webview.
import { createWebView, bridge } from "@webview-bridge/react-native";
import InAppBrowser from "react-native-inappbrowser-reborn";
// Register functions in the bridge object in your React Native code
export const appBridge = bridge({
async openInAppBrowser(url: string) {
if (await InAppBrowser.isAvailable()) {
await InAppBrowser.open(url);
} else {
throw new Error("InAppBrowser is not available")
}
},
// ... Add more functions as needed
});
// Export the bridge type to be used in the web application
export type AppBridge = typeof appBridge;Currently
import { linkBridge } from "@webview-bridge/web";
import type { AppBridge } from ""; // Import the type 'appBridge' declared in native
...
bridge.openInAppBrowser("http://localhost:5173").catch((err) => console.log(message)); // "{ name: 'NativeMethodError' }"Expected
import { linkBridge } from "@webview-bridge/web";
import type { AppBridge } from ""; // Import the type 'appBridge' declared in native
...
bridge.openInAppBrowser("http://localhost:5173").catch((err) => console.log(message)); // "Error: InAppBrowser is not available"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels