Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

usestate access previous state

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

// on a buttton for example
<button
  onClick={selectedObj => handleObjSelection(
              prevSelected => [...prevSelected, selectedObj],
  		  ))}
>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #usestate #access #previous #state
ADD COMMENT
Topic
Name
2+2 =