I am trying to load a script for true conversion, something like the following (I changed it a bit just to show as an example):
<script type="text/javascript"> var _tip = _tip || []; (function(d,s,id){ var js, tjs = d.getElementsByTagName(s)[0]; if(d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.async = true; js.src = d.location.protocol +'srcTrueConvrsion.js'; tjs.parentNode.insertBefore(js, tjs); }(document, 'script', 'ti-js'));</script>
I want to support the native(ios, android) in my app but also the web version. So I ended up doing something like this:
function getTrueConversionScript() { return `<script type="text/javascript"> var _tip = _tip || []; (function(d,s,id){ var js, tjs = d.getElementsByTagName(s)[0]; if(d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.async = true; js.src = d.location.protocol +'trueConversionSrc.js'; tjs.parentNode.insertBefore(js, tjs); }(document, 'script', 'ti-js'));</script> ` } {Platform.OS === 'web' ? (<View dangerouslySetInnerHTML={{ __html: getTrueConversionScript(), }} /> ) : (<WebView javaScriptEnabled source={{ html: getTrueConversionScript(), }} /> )}
If I try to use the webView for the web version in expo, I get the following error:
React Native WebView does not support this platform.
So I ended up trying to use dangerouslySetInnerHTML but seems like it is not a property of the View tag as typescript complains.
Any other solution to solve this?
Thanks!