Complete the code to import the useState hook from React.
import React, { [1] } from 'react';
The useState hook is imported from React to manage state in functional components.
Complete the code to declare a state variable called count with initial value 0.
const [count, setCount] = [1](0);
Use useState(0) to create a state variable count starting at 0.
Fix the error in the button's onClick handler to update the count state.
<button onClick={() => setCount([1])}>Increase</button>To update state, pass the new value count + 1 to setCount. Using count++ or assignments won't work correctly.
Fill both blanks to create a state variable named name with initial value 'Alice'.
const [[1], [2]] = useState('Alice');
The first element is the state variable name, and the second is the setter function setName.
Fill all three blanks to create a counter component with state and a button to increment.
import React, { [1] } from 'react'; export default function Counter() { const [[2], [3]] = useState(0); return ( <button onClick={() => [3]([2] + 1)}> Count: [2] </button> ); }
Import useState, declare state variable count and setter setCount, then update count on button click.