Before react, when I wanted some javascript code, I'd search online and grab a code snippet or find and add a script tag to my head tag. But that approach doesn't work with React. It's simple enough to download a file and then import * as whatever from whatever.js. Then run your code snippet in a useEffect(() => {}, []) block to emulator componentDidMount() behavior of running once after the dom element has mounted.

But! Now typescript and react are going to complain mightily about the whatever.js file you're importing. And oftentimes it will be minified, so now you're reading minified js, always a bad thing. So you start putting ignores at the top of the minified file, and it still doesn't work!

Don't go down this road. Instead, at the beginning of the process, find a react version of what you're looking for, preferably one that's packaged in npm. Using this will be straightforward.