add to current array react hooks code example
Example 1: adding to array using reach hooks
setMyArray(oldArray => [...oldArray, newElement]);
Example 2: add items to a react array in hooks
const addMessage = (newMessage) => setMessages(state => [newMessage, ...state])