PromisableWebView
A ReactNative WebView with a Promise-adapter.
This component is based on WKWebView which provides a bridge between
ReactNative context and the WebView context. That adapter allows you to
evaluateJavaScript()
code inside the WebView, and postMessage()
back to
ReactNative. Note that evaluateJavaScript()
does not return any value, so in
order to synchronize the ReactNative side needs to wait for some message to
return from the WebView.
This component wraps the WKWebView bridge and allows you to evaluate JS code within the WebView and get a Promise back:
thiswebview
Handling Page Loads
The WebView might unload the page while a Promise is in "pending" state -
either because the JavaScript code that evaluateJavaScriptWithPromise()
evaluates navigates away from the page, or because the web page decides to
reload or navigate away for some other reason.
In such cases the PromisableWebView
rejects any pending promises with
"WEBVIEW_RELOADED"
as the reason.