Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useSate object

[state, setState] = useState({})
const key = 'foo';
const value = 'bar';
setState(prevState => ({
  ...prevState,
  [key]: value
}));
 
PREVIOUS NEXT
Tagged: #useSate #object
ADD COMMENT
Topic
Name
9+4 =