Tests failing with Create a Controlled Form

It seems like I’ve completed the assignment correctly, but the code is saying that I am failing the tests with the handleSubmit function. I’ve double checked and I can’t find anything wrong.

  **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) {
    input: event.target.value
handleSubmit(event) {
  // Change code below this line
    submit: state.input
  // Change code above this line
render() {
  return (
      <form onSubmit={this.handleSubmit}>
        {/* Change code below this line */}
        <input onChange = {this.handleChange} value={this.state.input} />
        {/* Change code above this line */}
        <button type='submit' onSubmit = {this.handleSubmit}>Submit!</button>
      {/* Change code below this line */}
      {/* Change code above this line */}
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0

Challenge: Create a Controlled Form

Link to the challenge:


in the handleSubmit you are missing the this when setting the state value. You need to access this.state.input (so you need to apply same logic you are using in the render method when accessing the state values).

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.