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