Complete the code to import the React hook needed to manage state in a client component.
import React, { [1] } from 'react';
The useState hook is used to add state to functional components in React and Next.js client components.
Complete the code to declare a state variable called 'count' with initial value 0.
const [count, [1]] = useState(0);
The second element returned by useState is the function used to update the state variable. By convention, it is named starting with 'set' followed by the state variable name.
Complete the button text by adding a descriptive label before the count value.
"use client"; import { useState } from 'react'; export default function Counter() { const [count, setCount] = useState(0); return <button onClick={() => setCount(count + 1)}>[1]{count}</button>; }
The string before the count value in the button helps users understand what the number means. 'Count: ' is a clear label.
Fill in the blank to create a button that increments the count state by 1 when clicked.
const [count, setCount] = useState(0); return <button onClick={() => setCount(count [1] 1)}>Increment</button>;
The increment operation adds 1 to the current count using the + operator: setCount(count + 1).
Fill all three blanks to create a stateful input component that updates its value on change.
const [value, [1]] = useState(''); return <input type="text" value={value} onChange={e => [2]([3])} />;
The state updater function setValue is called with the new input value e.target.value when the input changes. The current state variable value is used as the input's value.