Next.js · Junior · Question 10 of 75

A component uses useState and onClick but crashes with an error. What's missing?

Explanation

State hooks and event handlers work only in client components. 'use client' declares the boundary of the client part. Best practice is to move interactivity into small client components and keep the page itself on the server.

Further reading

Problem with a question

Next.js · Junior · question 10

Test yourself

Take the Next.js · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz