React And Redux Manage State Locally First Help!

Tell us what’s happening:

Hey guys so I am having a hard time understanding why this doesn’t pass any help would be greatly appreciated, thanks again for all your help so far!

Your code so far

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) {
      messages: this.state.messages

  submitMessage() { = '';
       messages: this.state.messages.concat(this.state.input),
       input: ''
render() {
 const mappy = => <li key = {item + 1}>{item}</li>);
  return (
      <h2>Type in a new Message:</h2>
      { /* render an input, button, and ul here */ }
      <input onChange = {this.handleChange} value = {this.state.input}/>
      <button onClick = {this.submitMessage}>Submit</button>
      { /* change code above this line */ }

Your browser information:

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

Challenge: Manage State Locally First

Link to the challenge:

I’m curious why you are setting in submitMessage.

You have a JS function inside the render method which isn’t going to work.

yeah i figured this out eventually but idk what I was thinking lol, this section has got me hung up real bad conceptually

Keep pushing through. It’s the painful learning that leads to breakthroughs. :slight_smile:

1 Like