Recall & Review
beginner
What is the purpose of the
"use client" directive in Next.js?The
"use client" directive tells Next.js that a component should be rendered on the client side, enabling React hooks and browser-only features.Click to reveal answer
beginner
Where should you place the
"use client" directive in a Next.js component file?You must place
"use client" as the very first line at the top of the component file before any imports or code.Click to reveal answer
beginner
True or False: Components with
"use client" can use React hooks like useState and useEffect.True. The
"use client" directive enables React hooks that require client-side rendering.Click to reveal answer
intermediate
What happens if you forget to add
"use client" in a component that uses useState?Next.js will throw an error because
useState requires client-side rendering, which is not enabled without the "use client" directive.Click to reveal answer
intermediate
Can you use
"use client" in server components in Next.js?No. Server components run only on the server and cannot use
"use client". To use client features, create a separate client component with the directive.Click to reveal answer
What does the
"use client" directive enable in a Next.js component?✗ Incorrect
The
"use client" directive enables client-side rendering and allows React hooks like useState and useEffect.Where must the
"use client" directive be placed in a component file?✗ Incorrect
The directive must be the very first line in the file to be recognized properly.
What error occurs if you use
useState without "use client" in Next.js?✗ Incorrect
React hooks like
useState require client rendering, so missing the directive causes an error.Can a server component in Next.js use the
"use client" directive?✗ Incorrect
Server components run only on the server and cannot use client directives.
Why would you create a separate client component with
"use client" in Next.js?✗ Incorrect
Client components allow use of React hooks and browser-only features.
Explain the role of the
"use client" directive in Next.js and when you should use it.Think about what React hooks need to work.
You got /4 concepts.
Describe what happens if you try to use React hooks in a Next.js component without the
"use client" directive.Consider how Next.js distinguishes server and client components.
You got /4 concepts.