Hi guys,
I have an issue with my code. The code works correctly but if I click on the button “Run the Tests” I have has warring: “MyForm should return a div element which contains a form and an h1 tag. The form should include an input and a button.”
I don’t know what is wrong.
Any idea?
Many thanks for review the code.
class MyForm extends React.Component {
constructor(props) {
super(props);
this.state = {
input: '',
submit: ''
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({
input: event.target.value
});
}
handleSubmit(event) {
event.preventDefault();
this.setState({
input: '',
submit: this.state.input
});
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<h1>{this.state.submit}</h1>
<button type='submit'>Submit!</button>
</form>
<input value={this.state.input} onChange ={this.handleChange}/>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge: