Create a Controlled Form reactjs problem

Tell us what’s happening:
please tell me why my code isn’t working?

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) {
    // change code below this line
     event.preventDefault();
      this.setState({
        submit: event.target.value
      });
    };
    // change code above this line
  
  render() {
    return (
      <div>
        <form onSubmit={this.handleSubmit}>
          { /* change code below this line */ }
          <input type= "text" value={this.state.input} onChange={this.handleChange} />
          { /* change code above this line */ }
          <button type='submit'>Submit!</button>
        </form>
        { /* change code below this line */ }
        <h1>{this.state.submit}</h1>
        { /* change code above this line */ }
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/create-a-controlled-form

take a look in here. submit needs to be equal with “You should then complete the handleSubmit method so that it sets the component state property submit to the current input value in the local state”

1 Like

i really don’t understand what are you trying to tell me… can you please clear it for me . thank you

submit must be equal to " to the current input value in the local state" not equal to event.target.value

Oh I got it now!!! thank you so much, I have realised my mistake