Leonardo Russo 4 years ago
parent
commit
db529e265f
No account linked to committer's email address
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      docs/Guide.md

+ 2
- 1
docs/Guide.md View File

305
             uri:
305
             uri:
306
               'https://github.com/react-native-community/react-native-webview',
306
               'https://github.com/react-native-community/react-native-webview',
307
           }}
307
           }}
308
+          onMessage={(event) => {}}
308
           injectedJavaScript={runFirst}
309
           injectedJavaScript={runFirst}
309
         />
310
         />
310
       </View>
311
       </View>
313
 }
314
 }
314
 ```
315
 ```
315
 
316
 
316
-This runs the JavaScript in the `runFirst` string once the page is loaded. In this case, you can see that both the body style was changed to red and the alert showed up after 2 seconds.
317
+This runs the JavaScript in the `runFirst` string once the page is loaded. In this case, you can see that both the body style was changed to red and the alert showed up after 2 seconds. An `onMessage` event is required as well to inject the JavaScript code into the WebView.
317
 
318
 
318
 By setting `injectedJavaScriptForMainFrameOnly: false`, the JavaScript injection will occur on all frames (not just the main frame) if supported for the given platform. For example, if a page contains an iframe, the javascript will be injected into that iframe as well with this set to `false`. (Note this is not supported on Android.) There is also `injectedJavaScriptBeforeContentLoadedForMainFrameOnly` for injecting prior to content loading. Read more about this in the [Reference](./Reference.md#injectedjavascriptformainframeonly).
319
 By setting `injectedJavaScriptForMainFrameOnly: false`, the JavaScript injection will occur on all frames (not just the main frame) if supported for the given platform. For example, if a page contains an iframe, the javascript will be injected into that iframe as well with this set to `false`. (Note this is not supported on Android.) There is also `injectedJavaScriptBeforeContentLoadedForMainFrameOnly` for injecting prior to content loading. Read more about this in the [Reference](./Reference.md#injectedjavascriptformainframeonly).
319
 
320