Tell us what’s happening:
For the subject React challenge, I’m suppose to render a text input widget to permit a user to enter text. With whatever text is entered into the the widget, it is then suppose to render on the page .
All of the tests pass, but when I type characters into the text input widget the following error is raised: TypeError: event.target is null
.
What is causing this to occur?
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) => ({
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; rv:78.0) Gecko/20100101 Firefox/78.0
.
Challenge: Create a Controlled Input
Link to the challenge: