I've been tasked with inserting an embedded "Vidyard" video into a React project.
The embed code looks something like this.
<script type="text/javascript" async
src="https://play.vidyard.com/embed/v4.js">
</script>
<img
style="width: 100%; margin: auto; display: block;"
class="vidyard-player-embed"
src="xxxx"
data-uuid="xxxx"
data-v="4"
data-type="inline"
/>
This does not work 100% of the time.
When I insert this into a plain .html
file, the video shows up.
On the plain .html
file, the image loads and I believe the script then finds the image and drops the embedded video player on the DOM from there.
What I believe is happening is that there is a conflict between React/Vidyard as far as manipulating the DOM.
I've attempted to drop this directly into a component with no luck.
I've also added the script call directly to the <head>
.
I've followed Script load in react and attempted to manually call the script file, I also stuck the manual script load in both the componentWillMount
and componentDidMount
.
I've also inserted the code into dangerouslySetInnerHTML
.
The behavior remains the same.
Ideally if this was to work the image would append to the page. The embed/v4.js
script would then append a embedded video player on the image. Currently, the image appears and does not get switched out to a video. If i refresh/hard refresh the page, sometimes the image will swap out for the embedded video player.