Want to use external script that i add to ReactJS? You can load the script asynchronously and access it on load.
1 2 3 4 5 6 7 8 | componentDidMount() { const script = document.createElement("script"); script.src = "/static/libs/your_script.js"; script.async = true; script.onload = () => this.scriptLoaded(); document.body.appendChild(script); } |
It should get attached to the window.
1 2 3 | scriptLoaded() { window.A.sort(); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.