Complete the code to mark a React component as a client component in Next.js.
"use client"; export default function [1]() { return <div>Hello from client!</div>; }
In Next.js, to create a client component, you add the directive "use client"; at the top and export a React function component. The component name can be anything, but here ClientComponent is a clear choice.
Complete the code to import a client component correctly in a server component.
import [1] from './ClientComponent'; export default function ServerComponent() { return <div><[1] /></div>; }
When importing a client component, use the exact exported name with correct capitalization. React components must start with a capital letter, so ClientComponent is correct.
Fix the error in the client component declaration by completing the missing directive.
[1] export default function ClientWidget() { return <button>Click me</button>; }
The directive "use client"; must be a string literal at the top of the file to mark it as a client component in Next.js.
Fill both blanks to create a client component that uses a React hook.
"[1]"; import { useState } from 'react'; export default function Counter() { const [count, setCount] = useState(0); return <button onClick={() => setCount(count [2] 1)}>{count}</button>; }
Client components must start with the directive "use client";. To increase the count, use the + operator inside the setCount callback.
Fill all three blanks to create a client component that imports a child component and uses it inside JSX.
"[1]"; import Child from './Child'; export default function ClientWrapper() { return ( <div> <Child [2]="value" /> <button onClick={() => alert([3])}>Click</button> </div> ); }
The client component must start with "use client";. The child component can receive props like data-prop. The alert shows a string, so use "Hello" with quotes.