The input element should update the input property of the component's state

Tell us what’s happening:

Your code so far

class MyForm extends React.Component {
  constructor(props) {
    this.state = {
      input: '',
      submit: ''
    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  handleChange(event) {
  handleSubmit(event) {
    // change code below this line
    // change code above this line
  render() {
    return (
        <form onSubmit={this.handleSubmit}>
          { /* change code below this line */ }
<input value={this.props.input} onChange={this.handleChange}></input>
          { /* change code above this line */ }
          <button type='submit'>Submit!</button>
        { /* change code below this line */ }
        { /* change code above this line */ }

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:

so what you are doing wrong here is you re passing the props in input value whereas yu should be using the states like

<input value={this.state.input} onChange={this.handleChange}></input>. 

`You usually use props to pass down something to child component but you use state to get the current value of any component.and I think you should use the event.preventDefault() at first line of your function. It may not effect here but could give you some problems in future.

1 Like

Thank you very much, it works