Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

declaring multiple state variables in react

function ExampleWithManyStates() {
  // Declare multiple state variables!
  const [age, setAge] = useState(42);
  const [fruit, setFruit] = useState('banana');
  const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);
  // ...
}
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #declaring #multiple #state #variables #react
ADD COMMENT
Topic
Name
2+1 =