Create a Controlled Form advice

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 type="text" className='input' onChange={this.handleChange}  />
          { /* change code above this line */ }
          <button type='submit'>Submit!</button>
        { /* change code below this line */ }
        { /* change code above this line */ }

It is changing submit and input property value.but there are some problem

Hi @Tovuzlu, could you give a link to the free code camp lesson? And can your further explain what is the problem?

no. I dont know what is problem.
just freecodecam dont accept it

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 .

So you have to take input value not from the event, but from the current state.

1 Like

Thanks.i did but now i have a problem. Typing in the input element should update the input property of the component's state.

@Tovuzlu you are missing a prop that should be placed on your input element. Take a guess at what it is. If not, take a look at the lesson before this one.

Thanks pakatagoh

1 Like