title: React Native Webview how to use injectJavascript
body: <p>I'm trying to set a global variable within a webpage loaded by a react-native WebView. I'm trying to set the global variable using the injectJavascript prop, but I'm getting an error telling me that injectJavascript is expected to be a function. </p>
  
  <p>How do I format the injectJavaScript function to pass a message on to the loaded webpage as a global variable? Thank you.</p>
  
  <pre><code>class Browser extends React.Component {
  
    render() {
      const { url } = this.props;
      return (
        &lt;View&gt;
          &lt;WebView
            source={{ uri: url }}
            injectJavaScript={
              "window.testMessage = 'hello world'"
            }
          /&gt;
        &lt;/View&gt;
      );
    }
  }
  </code></pre>