user9345978
user9345978

Reputation:

can't find the missing comma

I'm fairly new to react so when don't be surprise if the question is very stupid. when I save and the code, I get "Unexpected token, expected , (24:2)" in the terminal, pls it points the sendChat function. any clue on where the comma is missing;

  componentDidUpdate(){
    setInterval(()=>{
        socket.on('chat',(data)=>{
        history.push(data);
        console.log(data);
    },1000);
  }

  sendChat(){ // points to the beginning of this line
    socket.emit('chat',{
      message:this.state.message
    });
  }

Upvotes: 0

Views: 274

Answers (1)

Anthony
Anthony

Reputation: 6482

componentDidUpdate(){
  setInterval(()=>{
    socket.on('chat',(data)=>{
       history.push(data);
       console.log(data);
   })    //<--------
  },1000);
}

You are missing a closing brace and parentheses at the indicated location

Upvotes: 2

Related Questions