Next.js
Choose a question track. Theory builds the concepts; debugging applies them to code and real problems.
Code-focused scenarios that ask you to diagnose behavior and choose a practical fix.
Next.js· Debugging & Problem SolvingSenior
Question 1 of 3
Scenario
An App Router product page fetches data on the server and has a 'favorite' toggle button.Code
tsx
// app/products/[id]/page.tsx
export default async function Page({ params }) {
const product = await getProduct(params.id);
const [fav, setFav] = useState(false);
return <>{product.name}<button onClick={() => setFav(!fav)}>★</button></>;
}