store state to array react hooks code example Example: React Hooks append state setTheArray(currentArray => [...currentArray, newElement])