react usestate state value still using previous value code example
Example: usestate access previous state
const [arrayOfObjs, handleObjSelection] = useState([]);
// on a buttton for example
<button
onClick={selectedObj => handleObjSelection(
prevSelected => [...prevSelected, selectedObj],
))}
>