Prabhu
Prabhu

Reputation: 1057

React Native using pass parameter with Load local HTML file into WebView

How can I pass props in Webview and get the props in my local html page

export default class HomeScreen extends React.Component {
  render() {
    return (
       <View>
            <WebView source={require('../Web/index.html')} />
          </View>  
    );
  }
}

Upvotes: 1

Views: 3977

Answers (1)

Khoa
Khoa

Reputation: 2932

You cannot pass any props to html page inside your Webview.

But there is a trick by using injectedJavascript https://facebook.github.io/react-native/docs/webview.html#injectedjavascript

Here is example: https://www.undefinednull.com/2015/12/27/injecting-custom-javascript-into-react-natives-webview/

Upvotes: 1

Related Questions