I'm trying to load external javascript (https://github.com/spite/ccapture.js) to my React.js component.
Currently the code looks like this:
let aScript = document.createElement('script');
aScript.type = 'text/javascript';
aScript.src = "CCapture.min.js";
document.head.appendChild(aScript);
This code correctly appends script to the page (checked the HTML). But now I'm wondering how can I use the contents of the script in a constructor function. Specifically, per the documentation - it would look something like this..
var capturer = new CCapture({
framerate: 60,
verbose: true
});
The error I'm getting says the CCapture is not defined. Am I missing something here? Not sure how to pull from the library itself.
I've added a function to make sure it is loading before the function itself runs per this instruction, https://stackoverflow.com/a/42848407/8497330.
I'm also not using the npm package because it does not work for the 'webm' format. Looking for a bandaid while the npm package is corrected.