I am trying to run a basic React Component in CodePen (I enabled Babel and I used React.Component ) but it still does not render. In the console it shows React not defined. I also took some already rendered code from another person and it does not work!!
class App extends React.Component {
constructor(props){
super(props);
this.state = {
term : ""
}
this.handleChange=this.handleChange.bind(this)
}
handleChange(event){
let term = event.target.value;
this.setState({term})
}
render() {
return (
<div className="App">
<input value={this.state.term} onChange={this.handleChange} />
{this.state.term}
</div>
);
}
}
ReactDOM.render(<App/> , document.getElementById("app"))
Follow these steps:
<div id="app"></div>
in the HTML section.Voila!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With