Reputation: 371
I want to pass a value from react-native to webview
<WebView
source={{
uri: 'https://accountant.aqilz.com/add-new-submit-form.php',
method: 'POST',
body: 'cat=cat',
}}
/>
Instead of hardcoded value cat=cat in the above code, I need to pass value from myId
.
const myId = this.props.route.params.email;
<WebView
source={{
uri: 'abcd.com/add-new-submit-form.php',
method: 'POST',
body: 'cat=???',
}}
/>
I want to pass the value from the const to the webview body. By doing this I can able to retrieve the login user email id.
Upvotes: 0
Views: 455
Reputation: 15462
You can use template literals:
const myId = this.props.route.params.email;
<WebView
source={{
uri: 'abcd.com/add-new-submit-form.php',
method: 'POST',
body: `cat=${myId}`,
}}
/>
You can also use standard string concatenation:
// ...
body: "cat=" + myId,
// ...
Upvotes: 2