I am dynamically appending scripts to my react app like this
export const appendScript = (scriptToAppend : string) => {
const script = document.createElement("script");
script.src = scriptToAppend;
script.async = true;
script.type = "text/jsx";
document.body.appendChild(script);
}
App Component
class App extends React.Component {
componentDidMount() {
appendScript("./assets/custom.min.js");
}
}
custom.min.js file
$(document).ready(function(){
alert("ready");
})