mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 11:41:08 +00:00
feat(iOS): Add callback for webViewWebContentProcessDidTerminate (#774)
* Add callback for WKWebView's onContentProcessDidTerminate * Add platform information to docs * Add new WebViewTerminatedEvent type
This commit is contained in:
committed by
Thibault Malbranche
parent
9c7bf57a9b
commit
a76811da93
@@ -17,6 +17,7 @@ This document lays out the current public properties and methods for the React N
|
||||
- [`onHttpError`](Reference.md#onhttperror)
|
||||
- [`onMessage`](Reference.md#onmessage)
|
||||
- [`onNavigationStateChange`](Reference.md#onnavigationstatechange)
|
||||
- [`onContentProcessDidTerminate`](Reference.md#oncontentprocessdidterminate)
|
||||
- [`originWhitelist`](Reference.md#originwhitelist)
|
||||
- [`renderError`](Reference.md#rendererror)
|
||||
- [`renderLoading`](Reference.md#renderloading)
|
||||
@@ -433,6 +434,40 @@ Note that this method will not be invoked on hash URL changes (e.g. from `https:
|
||||
|
||||
---
|
||||
|
||||
### `onContentProcessDidTerminate`
|
||||
|
||||
Function that is invoked when the `WebView` content process is terminated.
|
||||
|
||||
| Type | Required | Platform |
|
||||
| -------- | -------- | ------------- |
|
||||
| function | No | iOS WKWebView |
|
||||
|
||||
Example:
|
||||
|
||||
```jsx
|
||||
<WebView
|
||||
source={{ uri: 'https://facebook.github.io/react-native' }}
|
||||
onContentProcessDidTerminate={syntheticEvent => {
|
||||
const { nativeEvent } = syntheticEvent;
|
||||
console.warn('Content process terminated, reloading', nativeEvent);
|
||||
this.refs.webview.reload()
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
Function passed to onContentProcessDidTerminate is called with a SyntheticEvent wrapping a nativeEvent with these properties:
|
||||
|
||||
```
|
||||
canGoBack
|
||||
canGoForward
|
||||
loading
|
||||
target
|
||||
title
|
||||
url
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `originWhitelist`
|
||||
|
||||
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _just_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://*" and "https://*".
|
||||
|
||||
Reference in New Issue
Block a user