setMyArray(oldArray => [...oldArray, newElement]);
const addMessage = (newMessage) => setMessages(state => [...state, newMessage])