New to coding and react in general. I am wondering how to get this script(widget) from me index.html to appear in a component
index.html
// <div id="cibtWidgetHolder"></div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
var widgetHost = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js'
type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='"+ widgetHost + "cibtvisas.com/widget/widgetv2.js?
method=js&cibtCitizenship=USA&cibtCode=65490&cibtURL=balboa.com&cibtBG=e1f0f2&cibtHeader=1c171c&lang=en&cibtWidgetVersion=3' type='text/javascript'%3E%3C/script%3E"));
</script>
sections.js
<Col md="3">
<div id="cibtWidgetHolder"></div>
</Col>
If I call the div in index.html, it renders, but only at the bottom of the page, not with my other content in sections.js
I've seen this sort of usage for others asking similar questions, but am not sure how to implement with mine:
const useScript = url => {
useEffect(() => {
const script = document.createElement('script');
script.src = url;
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
}
}, [url]);
};
export default useScript;
Any help is appreciated!