Complete the code to import the hook used for state in Next.js components.
import { [1] } from 'react';
The useState hook is used to manage state in Next.js functional components.
Complete the code to create a state variable called 'count' with initial value 0.
const [count, setCount] = [1](0);
useState initializes a state variable and a function to update it.
Fix the error in the code by choosing the correct way to update state in Next.js.
setCount([1]);State updates must use the setter function with the new value, not increment operators.
Fill both blanks to create a server component that fetches data and passes it as a prop.
export default async function Page() {
const data = await fetch('/api/data').then(res => res.json());
return <ClientComponent [1]={data} [2]={data} />;
}The server component fetches data and passes it as a prop named data or items to the client component.
Fill all three blanks to correctly use a React client component with state and an event handler.
import { [1] } from 'react'; export default function Counter() { const [count, setCount] = [2](0); return <button onClick={() => setCount(count [3] 1)}>{count}</button>; }
Use useState to create state, and + to increment the count on button click.