Complete the code to mark a React component as a client component in Next.js.
"use client"; export default function [1]() { return <button>Click me</button>; }
In Next.js, to make a component a client component, you add "use client" at the top and export a React component. Naming it clearly like ClientButton helps understand its role.
Complete the code to import a client component correctly in a Next.js server component.
import [1] from './ClientButton'; export default function Page() { return <[1] />; }
You import the client component by its exact exported name. Here, ClientButton is the client component imported into a server component.
Fix the error in the client component declaration by completing the missing directive.
[1] import React from 'react'; export default function Clicker() { const [count, setCount] = React.useState(0); return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>; }
Client components in Next.js must start with the directive "use client"; to enable client-side features like state and events.
Fill both blanks to correctly use a client component with state and event in Next.js.
"use client"; import React, { [1] } from 'react'; export default function Counter() { const [count, setCount] = [2](0); return <button onClick={() => setCount(count + 1)}>Count: {count}</button>; }
The useState hook is imported and used to create state in a client component for interactive behavior.
Fill all three blanks to create a client component that uses state and effect.
"use client"; import React, { [1], [2] } from 'react'; export default function Timer() { const [seconds, setSeconds] = [3](0); React.useEffect(() => { const interval = setInterval(() => { setSeconds(s => s + 1); }, 1000); return () => clearInterval(interval); }, []); return <button>Seconds: {seconds}</button>; }
The component imports useState and useEffect. It uses useState to hold seconds and useEffect to update seconds every second.