Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. const writeMessage = (msg) => {
  2. setChat((prevState) => [...prevState, msg]);
  3. }
  4.  
  5. const writeMessage = (msg) => {
  6. //newChat = chat.concat(msg);
  7. //newChat = [...chat, msg]; this two takes inital State, but doesn not work with modified state
  8. //setChat(newChat);
  9. setChat(chat.push(newChat)); //this mutates :( and works, but does not re-render itself
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement