import a script to my react componetn
import React,{Component} from "react";
import ReactDOM from "react-dom";
import "./styles.css";
class App extends Component {
componentDidMount() {
const script = document.createElement("script"); script.async = true; script.src = "https://some-scripturl.js"; this.div.appendChild(script); }
render() {
return (
<div className="App" ref={el => (this.div = el)}> <h1>Hello react</h1>
{/* Script is inserted here */}
</div>
);
}
}
export default App;
Also in JavaScript:
- get random element from string array java
- react router url params
- replace non alphanumeric javascript
- update node two versions mac
- javascript function call with variable
- check to see if number is a decimal javascript
- element.value javascript
- import json file javascript
- javascript filter
- adding int and string in react props
- prototype chain in javascript
- Discord bot client login
- how to create a javascript hello world program with node.js
- how to print in java script
- get attribute value jquery
- how to add dropdown with filter in angular material
- jquery scroll to top of div animate
- json decode android
- class component react
- react.createref()
- promise catch
- eval in js
- SFC in react
- angular rebuild