const [array,setArray] = useState([]);
Push value at the end:
setArray(oldArray => [...oldArray,newValue] );
Push value at the start:
setArray(oldArray => [newValue,...oldArray] );
setMyArray(oldArray => [...oldArray, newElement]);
const addMessage = (newMessage) => setMessages(state => [...state, newMessage])