I need to upgrade to react-native-webview - react-native-webview/Guide.md at master · react-native-webview/react-native-webview · GitHub
I have found this similar question on the forum but is inconclusive - React-native-webview support? - #3 by sidechef
I can only find docs on https://docs.expo.io/versions/latest/react-native/webview/#__next
I have upgraded to SDK 33.0.0
I can’t work out from this post if react-native-webview is now available react-native-webview support | Voters | Expo
I have tried to use it and it renders html in a view, but I can’t get any javascript to run. Is it fully supported and is there any additional documentation please?
UPDATE
It seems the javascript does run using react-native-webview but postMessage does not work. With the below code the background colour changes but the onMessage is not received.
<WebView
originWhitelist={['*']}
source={localHtmlFile}
javaScriptEnabled={true}
injectedJavaScript={`
setTimeout(() => {
document.body.style.backgroundColor = 'blue';
window.ReactNativeWebView.postMessage("Hello!")
}, 3000);
true;
`}
onMessage={({ nativeEvent: state }) => {
console.warn(state.data)
}}
style={{width:200,height:200,backgroundColor:'blue',marginTop:20}}
/>
FURTHER UPDATE
It does work on an actual device! but not on the IOS simulator. I hope this saves other people a bit of time!