Tell us what’s happening:
Why the last one is not passing the tes.
Typing in the input element should update the state and the value of the input, and the p element should render this state as you type.
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(e) {
this.setState({
input: e.target.value
})
}
// change code above this line
render() {
return (
<div>
{ /* change code below this line */}
<input type="text" onChange={this.handleChange} value={this.state.value} />
{ /* change code above this line */}
<h4>Controlled Input:{this.state.input}</h4>
<p>{this.state.input}</p>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
.
Link to the challenge: