Sometimes, we want to call external JavaScript functions from React components.
In this article, we’ll look at how to call external JavaScript functions from React components.
Call External JavaScript Function from React Components
We can call external JavaScript functions from React components.
If we have something like:
<script>
function test(){
alert('hello world');
}
</script>
Then we created a global function that we can call in our React components.
Inside it, we write:
componentWillMount() {
window.test();
}
Conclusion
We can call external JavaScript functions from React components.