Manage State Locally First: Input Not Storing Locally

Tell us what’s happening:

I have tested variations on this code and am still getting the error “The input element should render the value of input in local state.” when I run the tests. I even double checked my work against solutions in the forums and don’t see a difference so not sure why its not passing?

PS - I have tried in Chrome, Firefox, and Edge. In the preview, my code functions as expected (except the input text does not clear, but that is passing test so not sure about that either)

Thanks

Your code so far


class DisplayMessages extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: '',
      messages: []
    }
  // add handleChange() and submitMessage() methods here
  this.handleChange = this.handleChange.bind(this);
  this.submitMessage = this.submitMessage.bind(this);
  }

  handleChange(event) {
    this.setState({
      input: event.target.value
      });
  }

  submitMessage(event) {
    const nowMsg = this.state.input;
    this.setState({
      messages: this.state.messages.concat(nowMsg),
      input: ''
    })
  }

  render() {
    const msgList = this.state.messages.map((msg) => <li>{msg}</li>)
    return (
      <div>
        <h2>Type in a new Message:</h2>
        { /* render an input, button, and ul here */ }
        <form>
        <input onChange={this.handleChange} value={this.state.value} /><br />
        <button onClick={this.submitMessage} value="submit">Add a Message</button>
        </form>
        <br />
        <ul>
        {msgList}        
        </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/72.0.3626.119 Safari/537.36.

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

You are very very close, hint: double check your input element’s value vs the component state’s.

Aaahhhhhhhhhh! Thank you very much!