Tell us what’s happening:
Why does it feel like i did this right … why is it presumably rendering like its supposed to but im not passing… should my h1 have a value of submit or something?
also, why cant i gain a feel of COMPETENCE with react in general… i really thought i did this one, i pushed the shift enter so ready to just move on … i dont UNDERSTAND
Your code so far
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({
submit : this.state.input
})
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<input value = {this.state.input} onChange = {this.handleChange} />
<button type='submit'>Submit!</button>
</form>
<h1> {this.state.submit}</h1>
</div>
);
}
}
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0
Challenge: React - Create a Controlled Form
Link to the challenge: