setstate object based off of previous state hooks react code example
Example: usestate access previous state
const [arrayOfObjs, handleObjSelection] = useState([]);
// on a buttton for example
<button
onClick={selectedObj => handleObjSelection(
prevSelected => [...prevSelected, selectedObj],
))}
>