Answers for "how to check previous values in react hooks"

0

usestate access previous state

const [arrayOfObjs, handleObjSelection] = useState([]);

// on a buttton for example
<button
  onClick={selectedObj => handleObjSelection(
              prevSelected => [...prevSelected, selectedObj],
  		  ))}
>
Posted by: Guest on February-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language