I have some code in React like this:
useEffect(() => {
TICautocapture(etc..);
That TICautocapture()
function is already defined in an external js file, let's say:
http:://some-cdn.example.com/library.js
So how could I use that library
methods on my React component?
I need it to be declared inside the Component, otherwise it wont find the name of the function.
by the way, I cant download the file locally because the library is being updated constantly, so I need to import from an external url.
EDIT:
The code of the library is like this:
// http:://some-cdn.example.com/library.js
var TICautocapture = (function(){
var lib = {...}
var error_handler;
var handleError = (error_code, error_callback) => {...}
function autocapture(container, options){...}
return autocapture;
})();
if(window.jQuery){
(function($){
$.fn.autocapture = function(options){
TICautocapture(this.attr('id'), options);
}
}(jQuery));
}
And from there I need to use the TICautocapture()
method.