Tell us what’s happening:
Describe your issue in detail here.
This React exercise had me create an input field. Whatever is typed in the input field should render just below the h1 tags. However, in the browser view, when I type in the input field, the display goes blank. I tested the code on codepen and it seems to work fine. Please advise.
**Your code so far**
class ControlledInput extends React.Component {
constructor(props) {
super(props);
this.state = {
input: ''
};
// Change code below this line
this.handleChange = this.handleChange.bind(this);
// Change code above this line
}
// Change code below this line
handleChange(event) {
this.setState((state, props) => ({input: event.target.value}));
}
// Change code above this line
render() {
return (
<div>
{ /* Change code below this line */}
<input type="text" value={this.state.input} onChange={this.handleChange} />
{ /* Change code above this line */}
<h4>Controlled Input:</h4>
<p>{this.state.input}</p>
</div>
);
}
};
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: React - Create a Controlled Input
Link to the challenge: