React - Create a Controlled Form

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:

To answer the second part of your question- I would think of this course as an intro to react. As you start to build projects on your own and make decisions on what to use when, I think you will build a greater understanding.

1 Like

actually the problem here was indent the h1 or at least indenting it resolved any conflicts that must have existed… but i see your point