Manage State Locally First - can't see the error

Manage State Locally First - can't see the error
0

#1

Tell us what’s happening:
This code fails for some reason to do with handleChange function not being defined?
I can’t see the issue.

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(e) {
  this.state.input = e.target.value
}
submitMessage(event) {
  event.preventDefault()
  let newMessages = this.state.messages
  this.setState({ messages : newMessages.concat(this.state.input)})
}
  render() {
    return (
      <div>
        <h2>Type in a new Message:</h2>
        { /* render an input, button, and ul here */ }
        <input type="text" onChange={handleChange}></input>
        <button onClick={submitMessage} value="Save message"></button>
        { /* change code above this line */ }
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react-and-redux/manage-state-locally-first


#2

You need to add this.handleChange and this.submit message. It’s a scoping issue in the render method. It doesn’t know what you mean by handleChange without “this”