Let’s say I have an external js file from other apps that cannot be modified. I can include that file in the index.html under script tag but I am not sure if that is the correct way. Also, how can I call any functions in that file from react components. “window.functionName” does not always seems to work.
One thing that might work, depending on the script, is to import it in your React component file.
import test from '../scripts/theScriptFile.js'
And then, again depending on the script, you might be able to call those functions like test.functionName()
or maybe even test()
.
1 Like