Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const writeMessage = (msg) => {
- setChat((prevState) => [...prevState, msg]);
- }
- const writeMessage = (msg) => {
- //newChat = chat.concat(msg);
- //newChat = [...chat, msg]; this two takes inital State, but doesn not work with modified state
- //setChat(newChat);
- setChat(chat.push(newChat)); //this mutates :( and works, but does not re-render itself
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement