Code Room
Code reviewHardcr-g189
Subject Hydration mismatchLevel Senior–Staff~24 minCommon in Storage & CDN interviewsIndustries Software development

Question

Review this React TypeScript component (Next.js App Router).

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewtsx
function ThemeToggle() {  const [theme, setTheme] = useState(    typeof window !== 'undefined' ? localStorage.getItem('theme') ?? 'light' : 'light'  );   return (    <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')} className={theme}>      Toggle theme    </button>  );}
Run or narrate your approach, then ask the coach.