React and Redux: Manage State Locally First Help!

Hi all,

So my code seems to work as intended (as far as I can tell), but I’m only passing a small portion of the tests on React and Redux: Manage State Locally First and I have no idea what I’m doing wrong. Thanks!

class DisplayMessages extends React.Component {
  constructor(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) {
    const  { name, value } =
    this.setState ({
      [name]: value

  submitMessage() {
    const blankState = ''
    const updatedMessage = [this.state.input]
    this.setState ({
      messages: [...this.state.messages, updatedMessage],
      input: blankState

  render() {
    const listItems = => <li>{item}</li>)
    return (
        <h2>Type in a new Message:</h2>

        <button onClick={this.submitMessage}>
          Add Message

I should check the test to be sure, but seems that they cannot pick up name from the

If you switch to an explicit declaration seems be more compliant with the test:

   this.setState ({
      input: value

Also, your submitMessage has an error, you will add a new array into messages:

    const updatedMessage = [this.state.input] // an array
    this.setState ({
      messages: [...this.state.messages, updatedMessage],

Hope it helps :+1:

1 Like

Yes! Thank you that made perfect sense and most definitely helped! :+1: