I have a chat application in React, I have a checkbox beside text when I click checkbox I take the text message. I just want to store the text in array. When I store the text I use this code:
this.setState(() =>{
this.state.allMessage.push(message.content.text);
});
But I can store only one, let's say I click checkbox and I send to the array "Hello world". Then I click checkbox "Hello Guys", and only this is stored to array. I just want to add like this:
allMessage: ["Hello World" , "Hello Guys"]
How can add like this.
Now, when I push "Hello Guys" then "Hello world" is deleting automatically.