@exodus/react-native-webview 11.26.1-exodus.7 → 11.26.1-exodus.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/package.json +1 -1
  2. package/.all-contributorsrc +0 -185
  3. package/.circleci/config.yml +0 -66
  4. package/.eslintignore +0 -2
  5. package/.eslintrc.js +0 -94
  6. package/.flowconfig +0 -88
  7. package/.flowconfig.android +0 -88
  8. package/.gitattributes +0 -12
  9. package/.github/CODEOWNERS +0 -1
  10. package/.github/ISSUE_TEMPLATE/bug-report.md +0 -42
  11. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -30
  12. package/.github/workflows/android-ci.yml +0 -35
  13. package/.github/workflows/detox.yml +0 -20
  14. package/.github/workflows/ios-ci.yml +0 -31
  15. package/.github/workflows/scripts/install-vs-features.ps1 +0 -108
  16. package/.github/workflows/stale.yml +0 -17
  17. package/.gitignore +0 -62
  18. package/.prettierrc.js +0 -10
  19. package/.releaserc +0 -15
  20. package/.vscode/settings.json +0 -9
  21. package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
  22. package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  23. package/android/.gradle/7.4.2/dependencies-accessors/gc.properties +0 -0
  24. package/android/.gradle/7.4.2/executionHistory/executionHistory.lock +0 -0
  25. package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
  26. package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
  27. package/android/.gradle/7.4.2/gc.properties +0 -0
  28. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  29. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  30. package/android/.gradle/vcs-1/gc.properties +0 -0
  31. package/babel.config.js +0 -11
  32. package/bin/setup +0 -26
  33. package/docs/Contributing.md +0 -102
  34. package/docs/Custom-Android.md +0 -222
  35. package/docs/Custom-iOS.md +0 -236
  36. package/docs/Debugging.md +0 -101
  37. package/docs/Getting-Started.md +0 -142
  38. package/docs/Guide.md +0 -613
  39. package/docs/Reference.md +0 -1629
  40. package/example/.gitignore +0 -14
  41. package/example/.watchmanconfig +0 -1
  42. package/example/App.tsx +0 -262
  43. package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
  44. package/example/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
  45. package/example/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
  46. package/example/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
  47. package/example/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
  48. package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
  49. package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
  50. package/example/android/.gradle/7.3.3/gc.properties +0 -0
  51. package/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  52. package/example/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  53. package/example/android/.gradle/vcs-1/gc.properties +0 -0
  54. package/example/android/build.gradle +0 -15
  55. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  56. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  57. package/example/android/gradle.properties +0 -34
  58. package/example/android/gradlew +0 -234
  59. package/example/android/gradlew.bat +0 -89
  60. package/example/android/settings.gradle +0 -12
  61. package/example/app.json +0 -20
  62. package/example/assets/test.html +0 -9
  63. package/example/babel.config.js +0 -3
  64. package/example/examples/Alerts.tsx +0 -72
  65. package/example/examples/ApplePay.tsx +0 -23
  66. package/example/examples/Background.tsx +0 -54
  67. package/example/examples/Downloads.tsx +0 -57
  68. package/example/examples/Injection.tsx +0 -161
  69. package/example/examples/LocalPageLoad.tsx +0 -16
  70. package/example/examples/Messaging.tsx +0 -63
  71. package/example/examples/NativeWebpage.tsx +0 -22
  72. package/example/examples/Scrolling.tsx +0 -68
  73. package/example/examples/Uploads.tsx +0 -69
  74. package/example/index.js +0 -9
  75. package/example/ios/Podfile +0 -8
  76. package/example/ios/Podfile.lock +0 -445
  77. package/ios/Podfile +0 -10
  78. package/ios/Podfile.lock +0 -3
  79. package/ios/Pods/Manifest.lock +0 -3
  80. package/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -397
  81. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/Pods-RNCWebView.xcscheme +0 -58
  82. package/ios/Pods/Pods.xcodeproj/xcuserdata/gabrielezenwankwo.xcuserdatad/xcschemes/xcschememanagement.plist +0 -16
  83. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-Info.plist +0 -26
  84. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.markdown +0 -3
  85. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-acknowledgements.plist +0 -29
  86. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-dummy.m +0 -5
  87. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView-umbrella.h +0 -16
  88. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.debug.xcconfig +0 -8
  89. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.modulemap +0 -6
  90. package/ios/Pods/Target Support Files/Pods-RNCWebView/Pods-RNCWebView.release.xcconfig +0 -8
  91. package/ios/RNCWebView.xcworkspace/contents.xcworkspacedata +0 -32
  92. package/jest-setups/jest.setup.js +0 -8
  93. package/jest.config.js +0 -184
  94. package/lib/UpdateOS.d.ts +0 -6
  95. package/lib/UpdateOS.d.ts.map +0 -1
  96. package/lib/UpdateOS.js +0 -49
  97. package/lib/WebView.android.d.ts.map +0 -1
  98. package/lib/WebView.d.ts.map +0 -1
  99. package/lib/WebView.ios.d.ts.map +0 -1
  100. package/lib/WebView.styles.d.ts.map +0 -1
  101. package/lib/WebViewNativeComponent.android.d.ts.map +0 -1
  102. package/lib/WebViewNativeComponent.ios.d.ts.map +0 -1
  103. package/lib/WebViewShared.d.ts.map +0 -1
  104. package/lib/WebViewTypes.d.ts.map +0 -1
  105. package/lib/index.d.ts.map +0 -1
  106. package/metro.config.js +0 -57
  107. package/src/WebView.android.tsx +0 -246
  108. package/src/WebView.ios.tsx +0 -221
  109. package/src/WebView.styles.ts +0 -44
  110. package/src/WebView.tsx +0 -18
  111. package/src/WebViewNativeComponent.android.ts +0 -8
  112. package/src/WebViewNativeComponent.ios.ts +0 -8
  113. package/src/WebViewShared.tsx +0 -257
  114. package/src/WebViewTypes.ts +0 -914
  115. package/src/__tests__/WebViewShared-test.js +0 -208
  116. package/src/__tests__/__snapshots__/WebViewShared-test.js.snap +0 -8
  117. package/src/index.ts +0 -4
  118. package/tsconfig.json +0 -24
  119. package/yarn.lock +0 -13895
package/docs/Reference.md DELETED
@@ -1,1629 +0,0 @@
1
- # React Native WebView API Reference
2
-
3
- This document lays out the current public properties and methods for the React Native WebView.
4
-
5
- ## Props Index
6
-
7
- - [`source`](Reference.md#source)
8
- - [`automaticallyAdjustContentInsets`](Reference.md#automaticallyadjustcontentinsets)
9
- - [`automaticallyAdjustsScrollIndicatorInsets`](Reference.md#automaticallyAdjustsScrollIndicatorInsets)
10
- - [`injectedJavaScript`](Reference.md#injectedjavascript)
11
- - [`injectedJavaScriptBeforeContentLoaded`](Reference.md#injectedjavascriptbeforecontentloaded)
12
- - [`injectedJavaScriptForMainFrameOnly`](Reference.md#injectedjavascriptformainframeonly)
13
- - [`injectedJavaScriptBeforeContentLoadedForMainFrameOnly`](Reference.md#injectedjavascriptbeforecontentloadedformainframeonly)
14
- - [`mediaPlaybackRequiresUserAction`](Reference.md#mediaplaybackrequiresuseraction)
15
- - [`nativeConfig`](Reference.md#nativeconfig)
16
- - [`onError`](Reference.md#onerror)
17
- - [`onRenderProcessGone`](Reference.md#onRenderProcessGone)
18
- - [`onLoad`](Reference.md#onload)
19
- - [`onLoadEnd`](Reference.md#onloadend)
20
- - [`onLoadStart`](Reference.md#onloadstart)
21
- - [`onLoadProgress`](Reference.md#onloadprogress)
22
- - [`onHttpError`](Reference.md#onhttperror)
23
- - [`onMessage`](Reference.md#onmessage)
24
- - [`onNavigationStateChange`](Reference.md#onnavigationstatechange)
25
- - [`onContentProcessDidTerminate`](Reference.md#oncontentprocessdidterminate)
26
- - [`onScroll`](Reference.md#onscroll)
27
- - [`originWhitelist`](Reference.md#originwhitelist)
28
- - [`renderError`](Reference.md#rendererror)
29
- - [`renderLoading`](Reference.md#renderloading)
30
- - [`scalesPageToFit`](Reference.md#scalespagetofit)
31
- - [`onShouldStartLoadWithRequest`](Reference.md#onshouldstartloadwithrequest)
32
- - [`startInLoadingState`](Reference.md#startinloadingstate)
33
- - [`style`](Reference.md#style)
34
- - [`containerStyle`](Reference.md#containerStyle)
35
- - [`decelerationRate`](Reference.md#decelerationrate)
36
- - [`domStorageEnabled`](Reference.md#domstorageenabled)
37
- - [`javaScriptEnabled`](Reference.md#javascriptenabled)
38
- - [`androidHardwareAccelerationDisabled`](Reference.md#androidHardwareAccelerationDisabled)
39
- - [`androidLayerType`](Reference.md#androidLayerType)
40
- - [`mixedContentMode`](Reference.md#mixedcontentmode)
41
- - [`thirdPartyCookiesEnabled`](Reference.md#thirdpartycookiesenabled)
42
- - [`userAgent`](Reference.md#useragent)
43
- - [`applicationNameForUserAgent`](Reference.md#applicationNameForUserAgent)
44
- - [`allowsInlineMediaPlayback`](Reference.md#allowsinlinemediaplayback)
45
- - [`allowsAirPlayForMediaPlayback`](Reference.md#allowsAirPlayForMediaPlayback)
46
- - [`bounces`](Reference.md#bounces)
47
- - [`overScrollMode`](Reference.md#overscrollmode)
48
- - [`contentInset`](Reference.md#contentinset)
49
- - [`contentInsetAdjustmentBehavior`](Reference.md#contentInsetAdjustmentBehavior)
50
- - [`contentMode`](Reference.md#contentMode)
51
- - [`dataDetectorTypes`](Reference.md#datadetectortypes)
52
- - [`scrollEnabled`](Reference.md#scrollenabled)
53
- - [`nestedScrollEnabled`](Reference.md#nestedscrollenabled)
54
- - [`setBuiltInZoomControls`](Reference.md#setBuiltInZoomControls)
55
- - [`setDisplayZoomControls`](Reference.md#setDisplayZoomControls)
56
- - [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
57
- - [`geolocationEnabled`](Reference.md#geolocationenabled)
58
- - [`url`](Reference.md#url)
59
- - [`html`](Reference.md#html)
60
- - [`keyboardDisplayRequiresUserAction`](Reference.md#keyboardDisplayRequiresUserAction)
61
- - [`hideKeyboardAccessoryView`](Reference.md#hidekeyboardaccessoryview)
62
- - [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
63
- - [`incognito`](Reference.md#incognito)
64
- - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
65
- - [`cacheEnabled`](Reference.md#cacheEnabled)
66
- - [`cacheMode`](Reference.md#cacheMode)
67
- - [`pagingEnabled`](Reference.md#pagingEnabled)
68
- - [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
69
- - [`sharedCookiesEnabled`](Reference.md#sharedCookiesEnabled)
70
- - [`textZoom`](Reference.md#textZoom)
71
- - [`pullToRefreshEnabled`](Reference.md#pullToRefreshEnabled)
72
- - [`onFileDownload`](Reference.md#onFileDownload)
73
- - [`limitsNavigationsToAppBoundDomains`](Reference.md#limitsNavigationsToAppBoundDomains)
74
- - [`textInteractionEnabled`](Reference.md#textInteractionEnabled)
75
- - [`mediaCapturePermissionGrantType`](Reference.md#mediaCapturePermissionGrantType)
76
- - [`autoManageStatusBarEnabled`](Reference.md#autoManageStatusBarEnabled)
77
- - [`setSupportMultipleWindows`](Reference.md#setSupportMultipleWindows)
78
- - [`basicAuthCredential`](Reference.md#basicAuthCredential)
79
- - [`enableApplePay`](Reference.md#enableApplePay)
80
- - [`forceDarkOn`](Reference.md#forceDarkOn)
81
- - [`useWebView2`](Reference.md#useWebView2)
82
- - [`minimumFontSize`](Reference.md#minimumFontSize)
83
- - [`downloadingMessage`](Reference.md#downloadingMessage)
84
- - [`lackPermissionToDownloadMessage`](Reference.md#lackPermissionToDownloadMessage)
85
- - [`allowsProtectedMedia`](Reference.md#allowsProtectedMedia)
86
-
87
- ## Methods Index
88
-
89
- - [`goForward`](Reference.md#goforward)
90
- - [`goBack`](Reference.md#goback)
91
- - [`reload`](Reference.md#reload)
92
- - [`stopLoading`](Reference.md#stoploading)
93
- - [`injectJavaScript`](Reference.md#injectjavascriptstr)
94
- - [`clearFormData`](Reference.md#clearFormData)
95
- - [`clearCache`](Reference.md#clearCachebool)
96
- - [`clearHistory`](Reference.md#clearHistory)
97
- - [`requestFocus`](Reference.md#requestFocus)
98
- - [`postMessage`](Reference.md#postmessagestr)
99
-
100
- ---
101
-
102
- # Reference
103
-
104
- ## Props
105
-
106
- ### `source`[⬆](#props-index)<!-- Link generated with jump2header -->
107
-
108
- Loads static HTML or a URI (with optional headers) in the WebView. Note that static HTML will require setting [`originWhitelist`](Reference.md#originwhitelist) to `["*"]`.
109
-
110
- The object passed to `source` can have either of the following shapes:
111
-
112
- **Load uri**
113
-
114
- - `uri` (string) - The URI to load in the `WebView`. Can be a local or remote file, and can be changed with React state or props to navigate to a new page.
115
- - `method` (string) - The HTTP Method to use. Defaults to GET if not specified. On Android and Windows, the only supported methods are GET and POST.
116
- - `headers` (object) - Additional HTTP headers to send with the request. On Android, this can only be used with GET requests. See the [Guide](Guide.md#setting-custom-headers) for more information on setting custom headers.
117
- - `body` (string) - The HTTP body to send with the request. This must be a valid UTF-8 string, and will be sent exactly as specified, with no additional encoding (e.g. URL-escaping or base64) applied. On Android and Windows, this can only be used with POST requests.
118
-
119
- **Static HTML**
120
-
121
- _Note that using static HTML requires the WebView property [originWhiteList](Reference.md#originWhiteList) to `['*']`. For some content, such as video embeds (e.g. Twitter or Facebook posts with video), the baseUrl needs to be set for the video playback to work_
122
-
123
- - `html` (string) - A static HTML page to display in the WebView.
124
- - `baseUrl` (string) - The base URL to be used for any relative links in the HTML. This is also used for the origin header with CORS requests made from the WebView. See [Android WebView Docs](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL)
125
-
126
- | Type | Required |
127
- | ------ | -------- |
128
- | object | No |
129
-
130
- ---
131
-
132
- ### `automaticallyAdjustContentInsets`[⬆](#props-index)<!-- Link generated with jump2header -->
133
-
134
- Controls whether to adjust the content inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value is `true`.
135
-
136
- | Type | Required | Platform |
137
- | ---- | -------- | -------- |
138
- | bool | No | iOS |
139
-
140
- ---
141
-
142
- ### `automaticallyAdjustsScrollIndicatorInsets`[⬆](#props-index)<!-- Link generated with jump2header -->
143
-
144
- Controls whether to adjust the scroll indicator inset for web views that are placed behind a navigation bar, tab bar, or toolbar. The default value `false`. (iOS 13+)
145
-
146
- | Type | Required | Platform |
147
- | ---- | -------- | -------- |
148
- | bool | No | iOS(13+) |
149
-
150
- ---
151
-
152
- ### `injectedJavaScript`[⬆](#props-index)<!-- Link generated with jump2header -->
153
-
154
- Set this to provide JavaScript that will be injected into the web page after the document finishes loading, but before other subresources finish loading.
155
-
156
- Make sure the string evaluates to a valid type (`true` works) and doesn't otherwise throw an exception.
157
-
158
- On iOS, see [`WKUserScriptInjectionTimeAtDocumentEnd`](https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentend?language=objc). Be sure
159
- to set an [`onMessage`](Reference.md#onmessage) handler, even if it's a no-op, or the code will not be run.
160
-
161
- | Type | Required | Platform |
162
- | ------ | -------- | ---------------------------- |
163
- | string | No | iOS, Android, macOS, Windows |
164
-
165
- To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
166
-
167
- _Kindly note: Windows does not have [native support for alerts](https://github.com/MicrosoftDocs/winrt-api/blob/docs/windows.ui.xaml.controls/webview.md#use-of-alert), as such any scripts to show an alert will not work._
168
-
169
- Example:
170
-
171
- Post message a JSON object of `window.location` to be handled by [`onMessage`](Reference.md#onmessage)
172
-
173
- ```jsx
174
- const INJECTED_JAVASCRIPT = `(function() {
175
- window.ReactNativeWebView.postMessage(JSON.stringify(window.location));
176
- })();`;
177
-
178
- <WebView
179
- source={{ uri: 'https://reactnative.dev' }}
180
- injectedJavaScript={INJECTED_JAVASCRIPT}
181
- onMessage={this.onMessage}
182
- />;
183
- ```
184
-
185
- ---
186
-
187
- ### `injectedJavaScriptBeforeContentLoaded`[⬆](#props-index)<!-- Link generated with jump2header -->
188
-
189
- Set this to provide JavaScript that will be injected into the web page after the document element is created, but before other subresources finish loading.
190
-
191
- Make sure the string evaluates to a valid type (`true` works) and doesn't otherwise throw an exception.
192
-
193
- On iOS, see [`WKUserScriptInjectionTimeAtDocumentStart`](https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentstart?language=objc)
194
-
195
- > **Warning**
196
- > On Android, this may work, but it is not 100% reliable (see [#1609](https://github.com/react-native-webview/react-native-webview/issues/1609) and [#1099](https://github.com/react-native-webview/react-native-webview/pull/1099)).
197
-
198
- | Type | Required | Platform |
199
- | ------ | -------- | ---------------------------------- |
200
- | string | No | iOS, macOS, Android (experimental) |
201
-
202
- To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
203
-
204
- Example:
205
-
206
- Post message a JSON object of `window.location` to be handled by [`onMessage`](Reference.md#onmessage). `window.ReactNativeWebView.postMessage` _will_ be available at this time.
207
-
208
- ```jsx
209
- const INJECTED_JAVASCRIPT = `(function() {
210
- window.ReactNativeWebView.postMessage(JSON.stringify(window.location));
211
- })();`;
212
-
213
- <WebView
214
- source={{ uri: 'https://reactnative.dev' }}
215
- injectedJavaScriptBeforeContentLoaded={INJECTED_JAVASCRIPT}
216
- onMessage={this.onMessage}
217
- />;
218
- ```
219
-
220
- ---
221
-
222
- ### `injectedJavaScriptForMainFrameOnly`[⬆](#props-index)<!-- Link generated with jump2header -->
223
-
224
- If `true` (default; mandatory for Android), loads the `injectedJavaScript` only into the main frame.
225
-
226
- If `false`, (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
227
-
228
- | Type | Required | Platform |
229
- | ---- | -------- | ------------------------------------------------- |
230
- | bool | No | iOS and macOS (only `true` supported for Android) |
231
-
232
- ---
233
-
234
- ### `injectedJavaScriptBeforeContentLoadedForMainFrameOnly`[⬆](#props-index)<!-- Link generated with jump2header -->
235
-
236
- If `true` (default; mandatory for Android), loads the `injectedJavaScriptBeforeContentLoaded` only into the main frame.
237
-
238
- If `false`, (only supported on iOS and macOS), loads it into all frames (e.g. iframes).
239
-
240
- | Type | Required | Platform |
241
- | ---- | -------- | ------------------------------------------------- |
242
- | bool | No | iOS and macOS (only `true` supported for Android) |
243
-
244
- ---
245
-
246
- ### `mediaPlaybackRequiresUserAction`[⬆](#props-index)<!-- Link generated with jump2header -->
247
-
248
- Boolean that determines whether HTML5 audio and video requires the user to tap them before they start playing. The default value is `true`. (Android API minimum version 17).
249
-
250
- NOTE: the default `true` value might cause some videos to hang loading on iOS. Setting it to `false` could fix this issue.
251
-
252
- | Type | Required | Platform |
253
- | ---- | -------- | ------------------- |
254
- | bool | No | iOS, Android, macOS |
255
-
256
- ---
257
-
258
- ### `nativeConfig`[⬆](#props-index)<!-- Link generated with jump2header -->
259
-
260
- Override the native component used to render the WebView. Enables a custom native WebView which uses the same JavaScript as the original WebView.
261
-
262
- The `nativeConfig` prop expects an object with the following keys:
263
-
264
- - `component` (any)
265
- - `props` (object)
266
- - `viewManager` (object)
267
-
268
- | Type | Required | Platform |
269
- | ------ | -------- | ------------------- |
270
- | object | No | iOS, Android, macOS |
271
-
272
- ---
273
-
274
- ### `onError`[⬆](#props-index)<!-- Link generated with jump2header -->
275
-
276
- Function that is invoked when the `WebView` load fails.
277
-
278
- | Type | Required |
279
- | -------- | -------- |
280
- | function | No |
281
-
282
- Example:
283
-
284
- ```jsx
285
- <WebView
286
- source={{ uri: 'https://reactnative.dev' }}
287
- onError={(syntheticEvent) => {
288
- const { nativeEvent } = syntheticEvent;
289
- console.warn('WebView error: ', nativeEvent);
290
- }}
291
- />
292
- ```
293
-
294
- Function passed to `onError` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
295
-
296
- ```
297
- canGoBack
298
- canGoForward
299
- code
300
- description
301
- didFailProvisionalNavigation
302
- domain
303
- loading
304
- target
305
- title
306
- url
307
- ```
308
-
309
- > **_Note_**
310
- > Domain is only used on iOS
311
-
312
- The `syntheticEvent` can be stopped doing its default action by calling `syntheticEvent.preventDefault()`.
313
-
314
- ---
315
-
316
- ### `onLoad`[⬆](#props-index)<!-- Link generated with jump2header -->
317
-
318
- Function that is invoked when the `WebView` has finished loading.
319
-
320
- | Type | Required |
321
- | -------- | -------- |
322
- | function | No |
323
-
324
- Example:
325
-
326
- ```jsx
327
- <WebView
328
- source={{ uri: 'https://reactnative.dev' }}
329
- onLoad={(syntheticEvent) => {
330
- const { nativeEvent } = syntheticEvent;
331
- this.url = nativeEvent.url;
332
- }}
333
- />
334
- ```
335
-
336
- Function passed to `onLoad` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
337
-
338
- ```
339
- canGoBack
340
- canGoForward
341
- loading
342
- target
343
- title
344
- url
345
- ```
346
-
347
- ---
348
-
349
- ### `onLoadEnd`[⬆](#props-index)<!-- Link generated with jump2header -->
350
-
351
- Function that is invoked when the `WebView` load succeeds or fails.
352
-
353
- | Type | Required |
354
- | -------- | -------- |
355
- | function | No |
356
-
357
- Example:
358
-
359
- ```jsx
360
- <WebView
361
- source={{ uri: 'https://reactnative.dev' }}
362
- onLoadEnd={(syntheticEvent) => {
363
- // update component to be aware of loading status
364
- const { nativeEvent } = syntheticEvent;
365
- this.isLoading = nativeEvent.loading;
366
- }}
367
- />
368
- ```
369
-
370
- Function passed to `onLoadEnd` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
371
-
372
- ```
373
- canGoBack
374
- canGoForward
375
- loading
376
- target
377
- title
378
- url
379
- ```
380
-
381
- ---
382
-
383
- ### `onLoadStart`[⬆](#props-index)<!-- Link generated with jump2header -->
384
-
385
- Function that is invoked when the `WebView` starts loading.
386
-
387
- | Type | Required |
388
- | -------- | -------- |
389
- | function | No |
390
-
391
- Example:
392
-
393
- ```jsx
394
- <WebView
395
- source={{ uri: 'https://reactnative.dev/=' }}
396
- onLoadStart={(syntheticEvent) => {
397
- // update component to be aware of loading status
398
- const { nativeEvent } = syntheticEvent;
399
- this.isLoading = nativeEvent.loading;
400
- }}
401
- />
402
- ```
403
-
404
- Function passed to `onLoadStart` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
405
-
406
- ```
407
- canGoBack
408
- canGoForward
409
- loading
410
- target
411
- title
412
- url
413
- ```
414
-
415
- ---
416
-
417
- ### `onLoadProgress`[⬆](#props-index)<!-- Link generated with jump2header -->
418
-
419
- Function that is invoked when the `WebView` is loading.
420
-
421
- | Type | Required | Platform |
422
- | -------- | -------- | ------------------- |
423
- | function | No | iOS, Android, macOS |
424
-
425
- Example:
426
-
427
- ```jsx
428
- <WebView
429
- source={{ uri: 'https://reactnative.dev' }}
430
- onLoadProgress={({ nativeEvent }) => {
431
- this.loadingProgress = nativeEvent.progress;
432
- }}
433
- />
434
- ```
435
-
436
- Function passed to `onLoadProgress` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
437
-
438
- ```
439
- canGoBack
440
- canGoForward
441
- loading
442
- progress
443
- target
444
- title
445
- url
446
- ```
447
-
448
- ---
449
-
450
- ### `onHttpError`[⬆](#props-index)<!-- Link generated with jump2header -->
451
-
452
- Function that is invoked when the `WebView` receives an http error.
453
-
454
- > **_Note_**
455
- > Android API minimum level 23.
456
-
457
- | Type | Required |
458
- | -------- | -------- |
459
- | function | No |
460
-
461
- Example:
462
-
463
- ```jsx
464
- <WebView
465
- source={{ uri: 'https://reactnative.dev' }}
466
- onHttpError={(syntheticEvent) => {
467
- const { nativeEvent } = syntheticEvent;
468
- console.warn(
469
- 'WebView received error status code: ',
470
- nativeEvent.statusCode,
471
- );
472
- }}
473
- />
474
- ```
475
-
476
- Function passed to `onHttpError` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
477
-
478
- ```
479
- canGoBack
480
- canGoForward
481
- description
482
- loading
483
- statusCode
484
- target
485
- title
486
- url
487
- ```
488
-
489
- > **_Note_**
490
- > Description is only used on Android
491
-
492
- ---
493
-
494
- ### `onRenderProcessGone`[⬆](#props-index)<!-- Link generated with jump2header -->
495
-
496
- Function that is invoked when the `WebView` process crashes or is killed by the OS on Android.
497
-
498
- > **_Note_**
499
- > Android API minimum level 26. Android Only
500
-
501
- | Type | Required |
502
- | -------- | -------- |
503
- | function | No |
504
-
505
- Example:
506
-
507
- ```jsx
508
- <WebView
509
- source={{ uri: 'https://reactnative.dev' }}
510
- onRenderProcessGone={syntheticEvent => {
511
- const { nativeEvent } = syntheticEvent;
512
- console.warn(
513
- 'WebView Crashed: ',
514
- nativeEvent.didCrash,
515
- );
516
- }}
517
- />
518
- ```
519
-
520
- Function passed to `onRenderProcessGone` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
521
-
522
- ```
523
- didCrash
524
- ```
525
- ---
526
-
527
- ### `onMessage`[⬆](#props-index)<!-- Link generated with jump2header -->
528
-
529
- Function that is invoked when the webview calls `window.ReactNativeWebView.postMessage`. Setting this property will inject this global into your webview.
530
-
531
- `window.ReactNativeWebView.postMessage` accepts one argument, `data`, which will be available on the event object, `event.nativeEvent.data`. `data` must be a string.
532
-
533
- | Type | Required |
534
- | -------- | -------- |
535
- | function | No |
536
-
537
- To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
538
-
539
- ---
540
-
541
- ### `onNavigationStateChange`[⬆](#props-index)<!-- Link generated with jump2header -->
542
-
543
- Function that is invoked when the `WebView` loading starts or ends.
544
-
545
- | Type | Required |
546
- | -------- | -------- |
547
- | function | No |
548
-
549
- Example:
550
-
551
- ```jsx
552
- <WebView
553
- source={{ uri: 'https://reactnative.dev' }}
554
- onNavigationStateChange={(navState) => {
555
- // Keep track of going back navigation within component
556
- this.canGoBack = navState.canGoBack;
557
- }}
558
- />
559
- ```
560
-
561
- The `navState` object includes these properties:
562
-
563
- ```
564
- canGoBack
565
- canGoForward
566
- loading
567
- navigationType (iOS only)
568
- target
569
- title
570
- url
571
- ```
572
-
573
- ---
574
-
575
- ### `onContentProcessDidTerminate`[⬆](#props-index)<!-- Link generated with jump2header -->
576
-
577
- Function that is invoked when the `WebView` content process is terminated.
578
-
579
- | Type | Required | Platform |
580
- | -------- | -------- | ----------------------- |
581
- | function | No | iOS and macOS WKWebView |
582
-
583
- iOS Web views use a separate process to render and manage web content. WebKit calls this method when the process for the specified web view terminates for any reason.
584
- The reason is not necessarily a crash. For instance, since iOS WebViews are not included in the total RAM of the app, they can be terminated independently of the app to liberate memory for new apps the user is opening. It's not unexpected to have WebViews get terminated after a while in the background.
585
-
586
- Example:
587
-
588
- ```jsx
589
- <WebView
590
- source={{ uri: 'https://reactnative.dev' }}
591
- onContentProcessDidTerminate={(syntheticEvent) => {
592
- const { nativeEvent } = syntheticEvent;
593
- console.warn('Content process terminated, reloading', nativeEvent);
594
- this.refs.webview.reload();
595
- }}
596
- />
597
- ```
598
-
599
- Function passed to onContentProcessDidTerminate is called with a SyntheticEvent wrapping a nativeEvent with these properties:
600
-
601
- ```
602
- canGoBack
603
- canGoForward
604
- loading
605
- target
606
- title
607
- url
608
- ```
609
-
610
- ---
611
-
612
- ### `onScroll`[⬆](#props-index)<!-- Link generated with jump2header -->
613
-
614
- Function that is invoked when the scroll event is fired in the `WebView`.
615
-
616
- | Type | Required | Platform |
617
- | -------- | -------- | ---------------------------- |
618
- | function | No | iOS, macOS, Android, Windows |
619
-
620
- Example:
621
-
622
- ```jsx
623
- <Webview
624
- source={{ uri: 'https://reactnative.dev' }}
625
- onScroll={syntheticEvent => {
626
- const { contentOffset } = syntheticEvent.nativeEvent
627
- console.table(contentOffset)
628
- }}
629
- />
630
- ```
631
-
632
- Function passed to `onScroll` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
633
-
634
- ```
635
- contentInset
636
- contentOffset
637
- contentSize
638
- layoutMeasurement
639
- velocity
640
- zoomScale
641
- ```
642
-
643
- ---
644
-
645
- ### `originWhitelist`[⬆](#props-index)<!-- Link generated with jump2header -->
646
-
647
- 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://*".
648
-
649
- | Type | Required | Platform |
650
- | ---------------- | -------- | ------------------- |
651
- | array of strings | No | iOS, Android, macOS |
652
-
653
- Example:
654
-
655
- ```jsx
656
- //only allow URIs that begin with https:// or git://
657
- <WebView
658
- source={{ uri: 'https://reactnative.dev' }}
659
- originWhitelist={['https://*', 'git://*']}
660
- />
661
- ```
662
-
663
- ---
664
-
665
- ### `renderError`[⬆](#props-index)<!-- Link generated with jump2header -->
666
-
667
- Function that returns a view to show if there's an error.
668
-
669
- | Type | Required | Platform |
670
- | -------- | -------- | ------------------- |
671
- | function | No | iOS, Android, macOS |
672
-
673
- Example:
674
-
675
- ```jsx
676
- <WebView
677
- source={{ uri: 'https://reactnative.dev' }}
678
- renderError={(errorName) => <Error name={errorName} />}
679
- />
680
- ```
681
-
682
- The function passed to `renderError` will be called with the name of the error
683
-
684
- ---
685
-
686
- ### `renderLoading`[⬆](#props-index)<!-- Link generated with jump2header -->
687
-
688
- Function that returns a loading indicator. The startInLoadingState prop must be set to true in order to use this prop.
689
-
690
- | Type | Required | Platform |
691
- | -------- | -------- | ------------------- |
692
- | function | No | iOS, Android, macOS |
693
-
694
- Example:
695
-
696
- ```jsx
697
- <WebView
698
- source={{ uri: 'https://reactnative.dev' }}
699
- startInLoadingState={true}
700
- renderLoading={() => <Loading />}
701
- />
702
- ```
703
-
704
- ---
705
-
706
- ### `scalesPageToFit`[⬆](#props-index)<!-- Link generated with jump2header -->
707
-
708
- Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. The default value is `true`.
709
-
710
- | Type | Required | Platform |
711
- | ---- | -------- | -------- |
712
- | bool | No | Android |
713
-
714
- ---
715
-
716
- ### `onShouldStartLoadWithRequest`[⬆](#props-index)<!-- Link generated with jump2header -->
717
-
718
- Function that allows custom handling of any web view requests. Return `true` from the function to continue loading the request and `false` to stop loading.
719
-
720
- On Android, is not called on the first load.
721
-
722
- | Type | Required | Platform |
723
- | -------- | -------- | ------------------- |
724
- | function | No | iOS, Android, macOS |
725
-
726
- Example:
727
-
728
- ```jsx
729
- <WebView
730
- source={{ uri: 'https://reactnative.dev' }}
731
- onShouldStartLoadWithRequest={(request) => {
732
- // Only allow navigating within this website
733
- return request.url.startsWith('https://reactnative.dev');
734
- }}
735
- />
736
- ```
737
-
738
- The `request` object includes these properties:
739
-
740
- ```
741
- title
742
- url
743
- loading
744
- target
745
- canGoBack
746
- canGoForward
747
- lockIdentifier
748
- mainDocumentURL (iOS only)
749
- navigationType (iOS only)
750
- isTopFrame (iOS only)
751
- ```
752
-
753
- ---
754
-
755
- ### `startInLoadingState`[⬆](#props-index)<!-- Link generated with jump2header -->
756
-
757
- Boolean value that forces the `WebView` to show the loading view on the first load. This prop must be set to `true` in order for the `renderLoading` prop to work.
758
-
759
- | Type | Required | Platform |
760
- | ---- | -------- | ------------------- |
761
- | bool | No | iOS, Android, macOS |
762
-
763
- ---
764
-
765
- ### `style`[⬆](#props-index)<!-- Link generated with jump2header -->
766
-
767
- A style object that allow you to customize the `WebView` style. Please note that there are default styles (example: you need to add `flex: 0` to the style if you want to use `height` property).
768
-
769
- | Type | Required |
770
- | ----- | -------- |
771
- | style | No |
772
-
773
- Example:
774
-
775
- ```jsx
776
- <WebView
777
- source={{ uri: 'https://reactnative.dev' }}
778
- style={{ marginTop: 20 }}
779
- />
780
- ```
781
-
782
- ---
783
-
784
- ### `containerStyle`[⬆](#props-index)<!-- Link generated with jump2header -->
785
-
786
- A style object that allow you to customize the `WebView` container style. Please note that there are default styles (example: you need to add `flex: 0` to the style if you want to use `height` property).
787
-
788
- | Type | Required |
789
- | ----- | -------- |
790
- | style | No |
791
-
792
- Example:
793
-
794
- ```jsx
795
- <WebView
796
- source={{ uri: 'https://reactnative.dev' }}
797
- containerStyle={{ marginTop: 20 }}
798
- />
799
- ```
800
-
801
- ---
802
-
803
- ### `decelerationRate`[⬆](#props-index)<!-- Link generated with jump2header -->
804
-
805
- A floating-point number that determines how quickly the scroll view decelerates after the user lifts their finger. You may also use the string shortcuts `"normal"` and `"fast"` which match the underlying iOS settings for `UIScrollViewDecelerationRateNormal` and `UIScrollViewDecelerationRateFast` respectively:
806
-
807
- - normal: 0.998
808
- - fast: 0.99 (the default for iOS web view)
809
-
810
- | Type | Required | Platform |
811
- | ------ | -------- | -------- |
812
- | number | No | iOS |
813
-
814
- ---
815
-
816
- ### `domStorageEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
817
-
818
- Boolean value to control whether DOM Storage is enabled. Used only in Android.
819
-
820
- | Type | Required | Platform |
821
- | ---- | -------- | -------- |
822
- | bool | No | Android |
823
-
824
- ---
825
-
826
- ### `javaScriptEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
827
-
828
- Boolean value to enable JavaScript in the `WebView`. The default value is `true`.
829
-
830
- | Type | Required |
831
- | ---- | -------- |
832
- | bool | No |
833
-
834
- ---
835
-
836
- ### `androidHardwareAccelerationDisabled`[⬆](#props-index)<!-- Link generated with jump2header -->
837
-
838
- **Deprecated.** Use the `androidLayerType` prop instead.
839
-
840
- | Type | Required | Platform |
841
- | ---- | -------- | -------- |
842
- | bool | No | Android |
843
-
844
- ---
845
-
846
- ### `androidLayerType`[⬆](#props-index)<!-- Link generated with jump2header -->
847
-
848
- Specifies the layer type.
849
-
850
- Possible values for `androidLayerType` are:
851
-
852
- - `none` (default) - The view does not have a layer.
853
- - `software` - The view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.
854
- - `hardware` - The view has a hardware layer. A hardware layer is backed by a hardware specific texture and causes the view to be rendered using Android's hardware rendering pipeline, but only if hardware acceleration is turned on for the view hierarchy.
855
-
856
- Avoid setting both `androidLayerType` and `androidHardwareAccelerationDisabled` props at the same time, as this may cause undefined behaviour.
857
-
858
- | Type | Required | Platform |
859
- | ------ | -------- | -------- |
860
- | string | No | Android |
861
-
862
- ---
863
-
864
- ### `mixedContentMode`[⬆](#props-index)<!-- Link generated with jump2header -->
865
-
866
- Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
867
-
868
- Possible values for `mixedContentMode` are:
869
-
870
- - `never` (default) - WebView will not allow a secure origin to load content from an insecure origin.
871
- - `always` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
872
- - `compatibility` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
873
-
874
- | Type | Required | Platform |
875
- | ------ | -------- | -------- |
876
- | string | No | Android |
877
-
878
- ---
879
-
880
- ### `thirdPartyCookiesEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
881
-
882
- Boolean value to enable third party cookies in the `WebView`. Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS. The default value is `true`. For more on cookies, read the [Guide](Guide.md#Managing-Cookies)
883
-
884
- | Type | Required | Platform |
885
- | ---- | -------- | -------- |
886
- | bool | No | Android |
887
-
888
- ---
889
-
890
- ### `userAgent`[⬆](#props-index)<!-- Link generated with jump2header -->
891
-
892
- Sets the user-agent for the `WebView`.
893
-
894
- | Type | Required | Platform |
895
- | ------ | -------- | ------------------- |
896
- | string | No | iOS, Android, macOS |
897
-
898
- ---
899
-
900
- ### `applicationNameForUserAgent`[⬆](#props-index)<!-- Link generated with jump2header -->
901
-
902
- Append to the existing user-agent. Setting `userAgent` will override this.
903
-
904
- | Type | Required | Platform |
905
- | ------ | -------- | ------------------- |
906
- | string | No | iOS, Android, macOS |
907
-
908
- ```jsx
909
- <WebView
910
- source={{ uri: 'https://reactnative.dev' }}
911
- applicationNameForUserAgent={'DemoApp/1.1.0'}
912
- />
913
- // Resulting User-Agent will look like:
914
- // Mozilla/5.0 (Linux; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.021; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36 DemoApp/1.1.0
915
- // Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 DemoApp/1.1.0
916
- ```
917
-
918
- ### `allowsInlineMediaPlayback`[⬆](#props-index)<!-- Link generated with jump2header -->
919
-
920
- Boolean that determines whether HTML5 videos play inline or use the native full-screen controller. The default value is `false`.
921
-
922
- > **NOTE**
923
- >
924
- > In order for video to play inline, not only does this property need to be set to `true`, but the video element in the HTML document must also include the `webkit-playsinline` attribute.
925
-
926
- | Type | Required | Platform |
927
- | ---- | -------- | -------- |
928
- | bool | No | iOS |
929
-
930
- ---
931
- ### `allowsAirPlayForMediaPlayback`[⬆](#props-index)<!-- Link generated with jump2header -->
932
-
933
- A Boolean value indicating whether AirPlay is allowed. The default value is `false`.
934
-
935
- | Type | Required | Platform |
936
- | ------- | -------- | ------------- |
937
- | boolean | No | iOS and macOS |
938
-
939
- ---
940
-
941
- ### `bounces`[⬆](#props-index)<!-- Link generated with jump2header -->
942
-
943
- Boolean value that determines whether the web view bounces when it reaches the edge of the content. The default value is `true`.
944
-
945
- | Type | Required | Platform |
946
- | ---- | -------- | -------- |
947
- | bool | No | iOS |
948
-
949
- ---
950
-
951
- ### `overScrollMode`[⬆](#props-index)<!-- Link generated with jump2header -->
952
-
953
- Specifies the over scroll mode.
954
-
955
- Possible values for `overScrollMode` are:
956
-
957
- - `always` (default) - Always allow a user to over-scroll this view, provided it is a view that can scroll.
958
- - `content` - Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.
959
- - `never` - Never allow a user to over-scroll this view.
960
-
961
- | Type | Required | Platform |
962
- | ------ | -------- | -------- |
963
- | string | No | Android |
964
-
965
- ---
966
-
967
- ### `contentInset`[⬆](#props-index)<!-- Link generated with jump2header -->
968
-
969
- The amount by which the web view content is inset from the edges of the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
970
-
971
- | Type | Required | Platform |
972
- | ------------------------------------------------------------------ | -------- | -------- |
973
- | object: {top: number, left: number, bottom: number, right: number} | No | iOS |
974
-
975
- ---
976
-
977
- ### `contentInsetAdjustmentBehavior`[⬆](#props-index)<!-- Link generated with jump2header -->
978
-
979
- This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is "never". Available on iOS 11 and later. Defaults to `never`.
980
-
981
- Possible values:
982
-
983
- - `automatic`
984
- - `scrollableAxes`
985
- - `never`
986
- - `always`
987
-
988
- | Type | Required | Platform |
989
- | ------ | -------- | -------- |
990
- | string | No | iOS |
991
-
992
- ---
993
-
994
- ### `contentMode`[⬆](#props-index)<!-- Link generated with jump2header -->
995
-
996
- Controls the type of content to load. Available on iOS 13 and later. Defaults to `recommended`, which loads mobile content on iPhone & iPad Mini but desktop content on larger iPads.
997
-
998
- See [Introducing Desktop-class Browsing on iPad](https://developer.apple.com/videos/play/wwdc2019/203/) for more.
999
-
1000
- Possible values:
1001
-
1002
- - `recommended`
1003
- - `mobile`
1004
- - `desktop`
1005
-
1006
- | Type | Required | Platform |
1007
- | ------ | -------- | -------- |
1008
- | string | No | iOS |
1009
-
1010
- ---
1011
-
1012
- ### `dataDetectorTypes`[⬆](#props-index)<!-- Link generated with jump2header -->
1013
-
1014
- Determines the types of data converted to clickable URLs in the web view's content. By default only phone numbers are detected.
1015
-
1016
- You can provide one type or an array of many types.
1017
-
1018
- Possible values for `dataDetectorTypes` are:
1019
-
1020
- - `phoneNumber`
1021
- - `link`
1022
- - `address`
1023
- - `calendarEvent`
1024
- - `none`
1025
- - `all`
1026
- - `trackingNumber`
1027
- - `flightNumber`
1028
- - `lookupSuggestion`
1029
-
1030
- | Type | Required | Platform |
1031
- | ---------------- | -------- | -------- |
1032
- | string, or array | No | iOS |
1033
-
1034
- ---
1035
-
1036
- ### `scrollEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1037
-
1038
- Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`. Setting this to `false` will prevent the webview from moving the document body when the keyboard appears over an input.
1039
-
1040
- | Type | Required | Platform |
1041
- | ---- | -------- | ------------- |
1042
- | bool | No | iOS and macOS |
1043
-
1044
- ---
1045
-
1046
- ### `nestedScrollEnabled`[⬆](#props-index)
1047
-
1048
- Boolean value that determines whether scrolling is possible in the `WebView` when used inside a `ScrollView` on Android. The default value is `false`.
1049
-
1050
- Setting this to `true` will prevent the `ScrollView` to scroll when scrolling from inside the `WebView`.
1051
-
1052
- | Type | Required | Platform |
1053
- | ---- | -------- | ------------- |
1054
- | bool | No | Android |
1055
-
1056
- ---
1057
-
1058
- ### `setBuiltInZoomControls`[⬆](#props-index)<!-- Link generated with jump2header -->
1059
-
1060
- Sets whether the WebView should use its built-in zoom mechanisms. The default value is `true`. Setting this to `false` will prevent the use of a pinch gesture to control zooming.
1061
-
1062
- | Type | Required | Platform |
1063
- | ---- | -------- | ------------- |
1064
- | bool | No | Android |
1065
-
1066
- ---
1067
-
1068
- ### `setDisplayZoomControls`[⬆](#props-index)<!-- Link generated with jump2header -->
1069
-
1070
- Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms (see `setBuiltInZoomControls`). The default value is `false`.
1071
-
1072
- | Type | Required | Platform |
1073
- | ---- | -------- | ------------- |
1074
- | bool | No | Android |
1075
-
1076
- ---
1077
-
1078
- ### `directionalLockEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1079
-
1080
- A Boolean value that determines whether scrolling is disabled in a particular direction.
1081
- The default value is `true`.
1082
-
1083
- | Type | Required | Platform |
1084
- | ---- | -------- | -------- |
1085
- | bool | No | iOS |
1086
-
1087
- ---
1088
-
1089
- ### `showsHorizontalScrollIndicator`[⬆](#props-index)<!-- Link generated with jump2header -->
1090
-
1091
- Boolean value that determines whether a horizontal scroll indicator is shown in the `WebView`. The default value is `true`.
1092
-
1093
- | Type | Required | Platform |
1094
- | ---- | -------- | ------------------- |
1095
- | bool | No | iOS, Android, macOS |
1096
-
1097
- ---
1098
-
1099
- ### `showsVerticalScrollIndicator`[⬆](#props-index)<!-- Link generated with jump2header -->
1100
-
1101
- Boolean value that determines whether a vertical scroll indicator is shown in the `WebView`. The default value is `true`.
1102
-
1103
- | Type | Required | Platform |
1104
- | ---- | -------- | ------------------- |
1105
- | bool | No | iOS, Android, macOS |
1106
-
1107
- ---
1108
-
1109
- ### `geolocationEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1110
-
1111
- Set whether Geolocation is enabled in the `WebView`. The default value is `false`. Used only in Android.
1112
-
1113
- | Type | Required | Platform |
1114
- | ---- | -------- | -------- |
1115
- | bool | No | Android |
1116
-
1117
- ---
1118
-
1119
- ### `url`[⬆](#props-index)<!-- Link generated with jump2header -->
1120
-
1121
- **Deprecated.** Use the `source` prop instead.
1122
-
1123
- | Type | Required |
1124
- | ------ | -------- |
1125
- | string | No |
1126
-
1127
- ---
1128
-
1129
- ### `html`[⬆](#props-index)<!-- Link generated with jump2header -->
1130
-
1131
- **Deprecated.** Use the `source` prop instead.
1132
-
1133
- | Type | Required |
1134
- | ------ | -------- |
1135
- | string | No |
1136
-
1137
- ---
1138
-
1139
- ### `keyboardDisplayRequiresUserAction`[⬆](#props-index)<!-- Link generated with jump2header -->
1140
-
1141
- If false, web content can programmatically display the keyboard. The default value is `true`.
1142
-
1143
- | Type | Required | Platform |
1144
- | ------- | -------- | -------- |
1145
- | boolean | No | iOS |
1146
-
1147
- ---
1148
-
1149
- ### `hideKeyboardAccessoryView`[⬆](#props-index)<!-- Link generated with jump2header -->
1150
-
1151
- If true, this will hide the keyboard accessory view (< > and Done).
1152
-
1153
- | Type | Required | Platform |
1154
- | ------- | -------- | -------- |
1155
- | boolean | No | iOS |
1156
-
1157
- ---
1158
-
1159
- ### `allowsBackForwardNavigationGestures`[⬆](#props-index)<!-- Link generated with jump2header -->
1160
-
1161
- If true, this will be able horizontal swipe gestures. The default value is `false`.
1162
-
1163
- | Type | Required | Platform |
1164
- | ------- | -------- | ------------- |
1165
- | boolean | No | iOS and macOS |
1166
-
1167
- ---
1168
-
1169
- ### `incognito`[⬆](#props-index)<!-- Link generated with jump2header -->
1170
-
1171
- Does not store any data within the lifetime of the WebView.
1172
-
1173
- | Type | Required | Platform |
1174
- | ------- | -------- | ------------------- |
1175
- | boolean | No | iOS, Android, macOS |
1176
-
1177
- ---
1178
-
1179
- ### `saveFormDataDisabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1180
-
1181
- Sets whether the WebView should disable saving form data. The default value is `false`. This function does not have any effect from Android API level 26 onwards as there is an Autofill feature which stores form data.
1182
-
1183
- | Type | Required | Platform |
1184
- | ------- | -------- | -------- |
1185
- | boolean | No | Android |
1186
-
1187
- ---
1188
-
1189
- ### `cacheEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1190
-
1191
- Sets whether WebView should use browser caching.
1192
-
1193
- | Type | Required | Default | Platform |
1194
- | ------- | -------- | ------- | ------------------- |
1195
- | boolean | No | true | iOS, Android, macOS |
1196
-
1197
- ---
1198
-
1199
- ### `cacheMode`[⬆](#props-index)<!-- Link generated with jump2header -->
1200
-
1201
- Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed. When navigating back, content is not revalidated, instead the content is just retrieved from the cache. This property allows the client to override this behavior.
1202
-
1203
- Possible values are:
1204
-
1205
- - `LOAD_DEFAULT` - Default cache usage mode. If the navigation type doesn't impose any specific behavior, use cached resources when they are available and not expired, otherwise load resources from the network.
1206
- - `LOAD_CACHE_ELSE_NETWORK` - Use cached resources when they are available, even if they have expired. Otherwise load resources from the network.
1207
- - `LOAD_NO_CACHE` - Don't use the cache, load from the network.
1208
- - `LOAD_CACHE_ONLY` - Don't use the network, load from the cache.
1209
-
1210
- | Type | Required | Default | Platform |
1211
- | ------ | -------- | ------------ | -------- |
1212
- | string | No | LOAD_DEFAULT | Android |
1213
-
1214
- ---
1215
-
1216
- ### `pagingEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1217
-
1218
- If the value of this property is true, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is false.
1219
-
1220
- | Type | Required | Platform |
1221
- | ------- | -------- | -------- |
1222
- | boolean | No | iOS |
1223
-
1224
- ---
1225
-
1226
- ### `allowsLinkPreview`[⬆](#props-index)<!-- Link generated with jump2header -->
1227
-
1228
- A Boolean value that determines whether pressing on a link displays a preview of the destination for the link. In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is true; before that, the default value is false.
1229
-
1230
- | Type | Required | Platform |
1231
- | ------- | -------- | ------------- |
1232
- | boolean | No | iOS and macOS |
1233
-
1234
- ---
1235
-
1236
- ### `sharedCookiesEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1237
-
1238
- Set `true` if shared cookies from `[NSHTTPCookieStorage sharedHTTPCookieStorage]` should used for every load request in the WebView. The default value is `false`. For more on cookies, read the [Guide](Guide.md#Managing-Cookies)
1239
-
1240
- | Type | Required | Platform |
1241
- | ------- | -------- | ------------- |
1242
- | boolean | No | iOS and macOS |
1243
-
1244
- ---
1245
-
1246
- ### `textZoom`[⬆](#props-index)<!-- Link generated with jump2header -->
1247
-
1248
- If the user has set a custom font size in the Android system, an undesirable scale of the site interface in WebView occurs.
1249
-
1250
- When setting the standard textZoom (100) parameter size, this undesirable effect disappears.
1251
-
1252
- | Type | Required | Platform |
1253
- | ------ | -------- | -------- |
1254
- | number | No | Android |
1255
-
1256
- Example:
1257
-
1258
- `<WebView textZoom={100} />`
1259
-
1260
- ---
1261
-
1262
- ### `pullToRefreshEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1263
-
1264
- Boolean value that determines whether a pull to refresh gesture is available in the `WebView`. The default value is `false`. If `true`, sets `bounces` automatically to `true`.
1265
-
1266
- | Type | Required | Platform |
1267
- | ------- | -------- | -------- |
1268
- | boolean | No | iOS |
1269
-
1270
- ### `onFileDownload`[⬆](#props-index)<!-- Link generated with jump2header -->
1271
- This property is iOS-only.
1272
-
1273
- Function that is invoked when the client needs to download a file.
1274
-
1275
- iOS 13+ only: If the webview navigates to a URL that results in an HTTP
1276
- response with a Content-Disposition header 'attachment...', then
1277
- this will be called.
1278
-
1279
- iOS 8+: If the MIME type indicates that the content is not renderable by the
1280
- webview, that will also cause this to be called. On iOS versions before 13,
1281
- this is the only condition that will cause this function to be called.
1282
-
1283
- The application will need to provide its own code to actually download
1284
- the file.
1285
-
1286
- If not provided, the default is to let the webview try to render the file.
1287
-
1288
- Example:
1289
-
1290
- ```jsx
1291
- <WebView
1292
- source={{ uri: 'https://reactnative.dev' }}
1293
- onFileDownload={({ nativeEvent: { downloadUrl } }) => {
1294
- // You use downloadUrl which is a string to download files however you want.
1295
- }}
1296
- />
1297
- ```
1298
-
1299
- | Type | Required | Platform |
1300
- | -------- | -------- | -------- |
1301
- | function | No | iOS |
1302
-
1303
- ---
1304
-
1305
- ### `limitsNavigationsToAppBoundDomains`[⬆](#props-index)<!-- Link generated with jump2header -->
1306
-
1307
- If true indicates to WebKit that a WKWebView will only navigate to app-bound domains. Only applicable for iOS 14 or greater.
1308
-
1309
- Once set, any attempt to navigate away from an app-bound domain will fail with the error “App-bound domain failure.”
1310
- Applications can specify up to 10 “app-bound” domains using a new Info.plist key `WKAppBoundDomains`. For more information see [App-Bound Domains](https://webkit.org/blog/10882/app-bound-domains/).
1311
-
1312
- | Type | Required | Platform |
1313
- | ------- | -------- | -------- |
1314
- | boolean | No | iOS |
1315
-
1316
- Example:
1317
-
1318
- ```jsx
1319
- <WebView limitsNavigationsToAppBoundDomains={true} />
1320
- ```
1321
-
1322
- ---
1323
-
1324
- ### `textInteractionEnabled`[⬆](#props-index)<!-- Link generated with jump2header -->
1325
-
1326
- If false indicates to WebKit that a WKWebView will not interact with text, thus not showing a text selection loop. Only applicable for iOS 14.5 or greater.
1327
-
1328
- Defaults to true.
1329
-
1330
- | Type | Required | Platform |
1331
- | ------- | -------- | -------- |
1332
- | boolean | No | iOS |
1333
-
1334
- Example:
1335
-
1336
- ```jsx
1337
- <WebView textInteractionEnabled={false} />
1338
- ```
1339
-
1340
- ---
1341
-
1342
- ### `mediaCapturePermissionGrantType`
1343
-
1344
- This property specifies how to handle media capture permission requests. Defaults to `prompt`, resulting in the user being prompted repeatedly. Available on iOS 15 and later.
1345
-
1346
- Possible values:
1347
-
1348
- - `grantIfSameHostElsePrompt`: If the security origin's host of the permission request equals the host of the WebView's current URL, the permission is granted if it has been granted before. Otherwise, the user gets prompted.
1349
- - `grantIfSameHostElseDeny`: If the security origin's host of the permission request equals the host of the WebView's current URL, the permission is granted if it has been granted before. Otherwise, it gets denied.
1350
- - `deny`
1351
- - `grant`: The permission is granted if it has been granted before.
1352
- - `prompt`
1353
-
1354
- Note that a grant may still result in a prompt, for example if the user has never been prompted for the permission before.
1355
-
1356
- | Type | Required | Platform |
1357
- | ------ | -------- | -------- |
1358
- | string | No | iOS |
1359
-
1360
- Example:
1361
-
1362
- ```javascript
1363
- <WebView mediaCapturePermissionGrantType={'grantIfSameHostElsePrompt'} />
1364
- ```
1365
-
1366
- ---
1367
-
1368
- ### `autoManageStatusBarEnabled`
1369
-
1370
- If set to `true`, the status bar will be automatically hidden/shown by WebView, specifically when full screen video is being watched. If `false`, WebView will not manage the status bar at all. The default value is `true`.
1371
-
1372
- | Type | Required | Platform |
1373
- | ------- | -------- | -------- |
1374
- | boolean | No | iOS |
1375
-
1376
- Example:
1377
-
1378
- ```javascript
1379
- <WebView autoManageStatusBarEnabled={false} />
1380
- ```
1381
-
1382
- ### `setSupportMultipleWindows`
1383
-
1384
- Sets whether the WebView supports multiple windows. See [Android documentation]('https://developer.android.com/reference/android/webkit/WebSettings#setSupportMultipleWindows(boolean)') for more information.
1385
- Setting this to false can expose the application to this [vulnerability](https://alesandroortiz.com/articles/uxss-android-webview-cve-2020-6506/) allowing a malicious iframe to escape into the top layer DOM.
1386
-
1387
- | Type | Required | Default | Platform |
1388
- | ------- | -------- | ------- | -------- |
1389
- | boolean | No | true | Android |
1390
-
1391
- Example:
1392
-
1393
- ```javascript
1394
- <WebView setSupportMultipleWindows={false} />
1395
- ```
1396
-
1397
- ### `enableApplePay`
1398
-
1399
- A Boolean value which, when set to `true`, WebView will be rendered with Apple Pay support. Once set, websites will be able to invoke Apple Pay from React Native Webview.
1400
- This comes with a cost features like [`injectJavaScript`](Reference.md#injectjavascriptstr), html5 History, [`sharedCookiesEnabled`](Reference.md#sharedCookiesEnabled), [`injectedJavaScript`](Reference.md#injectedjavascript), [`injectedJavaScriptBeforeContentLoaded`](Reference.md#injectedjavascriptbeforecontentloaded) will not work See [Apple Pay Release Note](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API).
1401
-
1402
- If you are required to send message to App , webpage has to explicitly call webkit message handler and receive it on `onMessage` handler on react native side
1403
- ```javascript
1404
- window.webkit.messageHandlers.ReactNativeWebView.postMessage("hello apple pay")
1405
- ```
1406
-
1407
- | Type | Required | Default | Platform |
1408
- | ------- | -------- | ------- | -------- |
1409
- | boolean | No | false | iOS |
1410
-
1411
- Example:
1412
-
1413
- ```javascript
1414
- <WebView enableApplePay={true} />
1415
- ```
1416
-
1417
- ### `forceDarkOn`
1418
-
1419
- Configuring Dark Theme
1420
-
1421
- *NOTE* : The force dark setting is not persistent. You must call the static method every time your app process is started.
1422
-
1423
- *NOTE* : The change from day<->night mode is a configuration change so by default the activity will be restarted and pickup the new values to apply the theme. Take care when overriding this default behavior to ensure this method is still called when changes are made.
1424
-
1425
- | Type | Required | Platform |
1426
- | ------- | -------- | -------- |
1427
- | boolean | No | Android |
1428
-
1429
- Example:
1430
-
1431
- ```javascript
1432
- <WebView forceDarkOn={false} />
1433
- ```
1434
- ### `menuItems`
1435
-
1436
- An array of custom menu item objects that will be appended to the UIMenu that appears when selecting text (will appear after 'Copy' and 'Share...'). Used in tandem with `onCustomMenuSelection`
1437
-
1438
- | Type | Required | Platform |
1439
- | ------------------------------------------------------------------ | -------- | -------- |
1440
- | array of objects: {label: string, key: string} | No | iOS |
1441
-
1442
- Example:
1443
-
1444
- ```javascript
1445
- <WebView menuItems={[{ label: 'Tweet', key: 'tweet' }, { label: 'Save for later', key: 'saveForLater' }]} />
1446
- ```
1447
-
1448
- ### `onCustomMenuSelection`
1449
-
1450
- Function called when a custom menu item is selected. It receives a Native event, which includes three custom keys: `label`, `key` and `selectedText`.
1451
-
1452
- | Type | Required | Platform |
1453
- | ------------------------------------------------------------------ | -------- | -------- |
1454
- | function | No | iOS |
1455
-
1456
- ```javascript
1457
- <WebView
1458
- menuItems={[{ label: 'Tweet', key: 'tweet' }, { label: 'Save for later', key: 'saveForLater' }]}
1459
- onCustomMenuSelection={(webViewEvent) => {
1460
- const { label } = webViewEvent.nativeEvent; // The name of the menu item, i.e. 'Tweet'
1461
- const { key } = webViewEvent.nativeEvent; // The key of the menu item, i.e. 'tweet'
1462
- const { selectedText } = webViewEvent.nativeEvent; // Text highlighted
1463
- }}
1464
- />
1465
- ```
1466
-
1467
- ### `basicAuthCredential`
1468
-
1469
- An object that specifies the credentials of a user to be used for basic authentication.
1470
-
1471
- - `username` (string) - A username used for basic authentication.
1472
- - `password` (string) - A password used for basic authentication.
1473
-
1474
- | Type | Required |
1475
- | ------ | -------- |
1476
- | object | No |
1477
-
1478
- ### `useWebView2`
1479
-
1480
- Use WinUI WebView2 control instead of WebView control as the native webview. The WebView2 control is a WinUI control that renders web content using the Microsoft Edge (Chromium) rendering engine. Option can be toggled at runtime and supports Fast Refresh.
1481
-
1482
- | Type | Required | Platform |
1483
- | ------- | -------- | -------- |
1484
- | boolean | No | Windows |
1485
-
1486
- Example:
1487
-
1488
- ```javascript
1489
- <WebView useWebView2={true} />
1490
- ```
1491
-
1492
- ### `minimumFontSize`
1493
-
1494
- Android enforces a minimum font size based on this value. A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. Default value is 8. If you are using smaller font sizes and are having trouble fitting the whole window onto one screen, try setting this to a smaller value.
1495
-
1496
- | Type | Required | Platform |
1497
- | ------ | -------- | -------- |
1498
- | number | No | Android |
1499
-
1500
- Example:
1501
-
1502
- ```javascript
1503
- <WebView minimumFontSize={1} />
1504
- ```
1505
-
1506
- ### `downloadingMessage`
1507
-
1508
- This is the message that is shown in the Toast when downloading a file via WebView. Default message is "Downloading".
1509
-
1510
- | Type | Required | Platform |
1511
- | ------ | -------- | -------- |
1512
- | string | No | Android |
1513
-
1514
- ### `lackPermissionToDownloadMessage`
1515
-
1516
- This is the message that is shown in the Toast when the webview is unable to download a file. Default message is "Cannot download files as permission was denied. Please provide permission to write to storage, in order to download files.".
1517
-
1518
- | Type | Required | Platform |
1519
- | ------ | -------- | -------- |
1520
- | string | No | Android |
1521
-
1522
- ### `allowsProtectedMedia`
1523
-
1524
- Whether or not the Webview can play media protected by DRM. Default is false.
1525
- /!\ Setting this to false won't revoke the permission already granted to the current webpage. In order to do so, you'd have to reload the page as well. /!\
1526
-
1527
- | Type | Required | Platform |
1528
- | ------ | -------- | -------- |
1529
- | boolean | No | Android |
1530
-
1531
- ## Methods
1532
-
1533
- ### `goForward()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1534
-
1535
- ```javascript
1536
- goForward();
1537
- ```
1538
-
1539
- Go forward one page in the web view's history.
1540
-
1541
- ### `goBack()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1542
-
1543
- ```javascript
1544
- goBack();
1545
- ```
1546
-
1547
- Go back one page in the web view's history.
1548
-
1549
- ### `reload()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1550
-
1551
- ```javascript
1552
- reload();
1553
- ```
1554
-
1555
- Reloads the current page.
1556
-
1557
- ### `stopLoading()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1558
-
1559
- ```javascript
1560
- stopLoading();
1561
- ```
1562
-
1563
- Stop loading the current page.
1564
-
1565
- ### `injectJavaScript(str)`[⬆](#methods-index)<!-- Link generated with jump2header -->
1566
-
1567
- ```javascript
1568
- injectJavaScript('... javascript string ...');
1569
- ```
1570
-
1571
- Executes the JavaScript string.
1572
-
1573
- To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
1574
-
1575
- ### `requestFocus()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1576
-
1577
- ```javascript
1578
- requestFocus();
1579
- ```
1580
-
1581
- Request the webView to ask for focus. (People working on TV apps might want having a look at this!)
1582
-
1583
- ### `postMessage(str)`[⬆](#methods-index)<!-- Link generated with jump2header -->
1584
-
1585
- ```javascript
1586
- postMessage('message');
1587
- ```
1588
-
1589
- Post a message to WebView, handled by [`onMessage`](Reference.md#onmessage).
1590
-
1591
- ### `clearFormData()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1592
-
1593
- (android only)
1594
-
1595
- ```javascript
1596
- clearFormData();
1597
- ```
1598
-
1599
- Removes the autocomplete popup from the currently focused form field, if present. [developer.android.com reference](<https://developer.android.com/reference/android/webkit/WebView.html#clearFormData()>)
1600
-
1601
- ### `clearCache(bool)`[⬆](#methods-index)<!-- Link generated with jump2header -->
1602
-
1603
- (android only)
1604
-
1605
- ```javascript
1606
- clearCache(true)
1607
- ```
1608
-
1609
- Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used. [developer.android.com reference](<https://developer.android.com/reference/android/webkit/WebView.html#clearCache(boolean)>)
1610
-
1611
- ### `clearHistory()`[⬆](#methods-index)<!-- Link generated with jump2header -->
1612
-
1613
- (android only)
1614
-
1615
- ```javascript
1616
- clearHistory();
1617
- ```
1618
-
1619
- Tells this WebView to clear its internal back/forward list. [developer.android.com reference](<https://developer.android.com/reference/android/webkit/WebView.html#clearHistory()>)
1620
-
1621
- ## Other Docs
1622
-
1623
- Also check out our [Getting Started Guide](Getting-Started.md) and [In-Depth Guide](Guide.md).
1624
-
1625
- ## Translations
1626
-
1627
- This file is available at:
1628
-
1629
- - [Brazilian portuguese](Reference.portuguese.md)