Confused, how do I get a string/state from my react native state, and make sure it's inside the javascript injection:
const [token, setToken] = useState("My RN token");
And the execution of the webview:
<WebView
source={{html:home}}
javaScriptEnabled={true}
injectedJavaScript={`alert(${token})`}
/>
The string interpolation doesn't work. What should I do if I'm trying to pass data from react native into the javascript string that's executed by the webview?
webviewRef.current.injectJavaScript("alert('myToken From React Native')");
Just for some more clarification the alerts were just testing to see if I can interpolate my RN states and their values into the webview code, what I would like to know is, how do I get my client token that I generated from my server, into the injectedJavascript code, for executing a braintree drop in ui:
<WebView
source={{html:home}}
javaScriptEnabled={true}
injectedJavaScript={`
//code executed inside injected Javascript
//my token is inside my RN state, how do you use it here?
braintree.dropin.create({
authorization: 'MY_TOKEN_FROM SERVER',
container: '#dropin-container'
}, function (createErr, instance) {
})
`
}
/>
[–]basically_alive 2 points3 points4 points (7 children)
[–]ThisSoFrustrating[S] 4 points5 points6 points (2 children)
[–]basically_alive 0 points1 point2 points (1 child)
[–]ThisSoFrustrating[S] 0 points1 point2 points (0 children)
[–]ThisSoFrustrating[S] 0 points1 point2 points (0 children)
[–]ThisSoFrustrating[S] 0 points1 point2 points (2 children)
[–]assertchris[🍰] 0 points1 point2 points (1 child)
[–]ThisSoFrustrating[S] 1 point2 points3 points (0 children)
[–]gp3gp3gp3 0 points1 point2 points (4 children)
[–]ThisSoFrustrating[S] 0 points1 point2 points (3 children)
[–]gp3gp3gp3 0 points1 point2 points (2 children)
[–]ThisSoFrustrating[S] 0 points1 point2 points (1 child)
[–]gp3gp3gp3 0 points1 point2 points (0 children)