瀏覽代碼

chore(docs): Adds example for onShouldStartLoadWithRequest (#321)

Per #320, this adds an example for onShouldStartLoadWithRequest.
Jamon Holmgren 5 年之前
父節點
當前提交
d28071cf52
共有 1 個檔案被更改,包括 25 行新增0 行删除
  1. 25
    0
      docs/Reference.md

+ 25
- 0
docs/Reference.md 查看文件

@@ -268,6 +268,31 @@ On Android, is not called on the first load.
268 268
 | -------- | -------- |
269 269
 | function | No       |
270 270
 
271
+Example:
272
+
273
+```jsx
274
+<WebView
275
+  source={{ uri: "https://facebook.github.io/react-native" }}
276
+  onShouldStartLoadWithRequest={(request) => {
277
+    // Only allow navigating within this website
278
+    return request.url.startsWith("https://facebook.github.io/react-native")
279
+  }}
280
+/>
281
+```
282
+
283
+The `request` object includes these properties:
284
+
285
+```
286
+title
287
+url
288
+loading
289
+target
290
+canGoBack
291
+canGoForward
292
+lockIdentifier
293
+navigationType
294
+```
295
+
271 296
 ---
272 297
 
273 298
 ### `startInLoadingState`