react hooks add to array in state by index code example
Example: add items to a react array in hooks
const addMessage = (newMessage) => setMessages(state => [...state, newMessage])
const addMessage = (newMessage) => setMessages(state => [...state, newMessage])