Intermedio
18 novembre 2026Trova il bug: React / Next.js
Uno snippet di codice. Trova il bug, o dimostra che non ce n'è.
tsx
1import { useState, useCallback, memo } from 'react'
2
3const Row = memo(({ label, onClick }: { label: string; onClick: () => void }) => {
4 return <li onClick={onClick}>{label}</li>
5})
6
7function TodoList({ items }: { items: string[] }) {
8 const [selected, setSelected] = useState<string | null>(null)
9
10 const handleClick = useCallback((label: string) => {
11 setSelected(label)
12 }, [selected])
13
14 return (
15 <ul>
16 {items.map(i => <Row key={i} label={i} onClick={() => handleClick(i)} />)}
17 </ul>
18 )
19}Clicca sulle righe che causano il problema.
Il tuo verdetto
Un tentativo al giorno. La risposta appare subito dopo.
Mantieni la tua serie
Crea un account per conservare la tua serie e seguire i tuoi progressi.