react-native/Examples
Luke Miles da9a712a9e Add a injectJavaScript method to the WebView component
Summary:
Currently, < WebView > allows you to pass JS to execute within the view. This works great, but there currently is not a way to execute JS after the page is loaded. We needed this for our app.

We noticed that the WebView had messaging support added (see #9762) . Initially, this seemed like more than enough functionality for our use case - just write a function that's injected on initial load that accepts a message with JS, and `eval()` it. However, this broke once we realized that Content Security Policy can block the use of eval on pages. The native methods iOS provide to inject JS allow you to inject JS without CSP interfering. So, we just wrapped the native methods on iOS (and later Android) and it worked for our use case. The method injectJavaScript was born.

Now, after I wrote this code, I realized that #8798 exists and hadn't been merged because of a lack of tests. I commend what was done in #8798 as it sorely solves a problem (injecting JS after the initial load) and has more features than what I'
Closes https://github.com/facebook/react-native/pull/11358

Differential Revision: D4390425

fbshipit-source-id: 02813127f8cf60fd84229cb26eeea7f8922d03b3
2017-01-06 20:29:02 -08:00
..
2048 Update React Native minimum OS version to iOS8 2016-09-01 19:43:47 -07:00
Movies BREAKING: Android - ReactNativeHost getUseDeveloperSupport to public #2 2016-12-15 21:13:38 -08:00
TicTacToe BREAKING: Android - ReactNativeHost getUseDeveloperSupport to public #2 2016-12-15 21:13:38 -08:00
UIExplorer Add a injectJavaScript method to the WebView component 2017-01-06 20:29:02 -08:00
.eslintrc Add global flow types to eslint globals 2016-01-27 15:55:34 -08:00