0

I am looking to use Google's cast SDK (for sending) in the Web app that I am working on; In google's documentation and codelabs (https://developers.google.com/cast/codelabs#:~:text=Codelabs%20are%20sample%20apps%20with,Also%20see%20Sample%20applications.) it seems that the only way to load the SDK is to use

<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>

This won't work for me because I am writing a React+JSX web app. I can't just load the script through a script tag as the other elements that need to get rendered, such as the

<google-cast-launcher id="castbutton"></google-cast-launcher>

Aren't recognized as valid JSX elements. How can I make this library available to my code? Is there anything like

yarn add cast-sdk

that exists that I can use to get the sdk?

1 Answers1

0

You can load the script directly on your index.html file. This way the script will load once together with your App.

Or you can dynamically load the script in the js like it is explained here, but this way the script will be loaded/unloaded every time the component is mounted/unmounted.

ebbishop
  • 1,833
  • 2
  • 20
  • 45
Tiagocf2
  • 50
  • 3