React and Redux - Manage State Locally First

My code does not generate the last two checkmarks. I am not sure what is wrong.

  **Your code so far**
class DisplayMessages extends React.Component {
constructor(props) {
  super(props);
  this.state = {
    input: '',
    messages: []
  }
this.handleChange = this.handleChange.bind(this);
this.submitMessage = this.submitMessage.bind(this);
}
// Add handleChange() and submitMessage() methods here
handleChange (event) {
  this.setState({
    input: event.target.value,
    messages: this.state.messages//this line is only nessecary for multiple inputs
  })
}
submitMessage() {
  this.setState({
    input: '',
    messages: [...this.state.message, this.state.input]
  })
}
render() {
  return (
    <div>
      <h2>Type in a new Message:</h2>
      { /* Render an input, button, and ul below this line */ }
      <input value={this.state.input} onChange={this.handleChange}/>
      <p>{this.state.input}</p>
        <button onClick={this.submitMessage}>Submit</button>
        <ul>  {this.state.messages.map((x, i)=>{
          return <li key={i}>{x}</li>
        })}
        </ul>
      { /* Change code above this line */ }
    </div>
  );
}
};
  **Your browser information:**

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

Challenge: React and Redux - Manage State Locally First

Link to the challenge:

In your submitMessage function, you are missing an s at the end of messages which is causing the error.

Hope this helps!

It does. Thanks so much!

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