All jobs / Full-stack developer / Frontend
Full-stack developer interview question · 1–3 years
A Next-style SSR page flashes and React logs a hydration mismatch on the header.
What do you fix first?
The strongest answer
Make the first client render match the HTML the server sent — same data, same locale, no `window`-only branches on that path
Why it works
Exactly. Hydration is a diff against the server HTML. Auth, clocks and locale are the usual liars — give the client the same snapshot.
What a good answer covers
- First client paint must equal server HTML.
- Pass the same user, locale and time snapshot.
- Keep `window` and `localStorage` out of that first render.
- Do not paper over the warning.
Answers that fall short
- Close, but not the strongest: Wrap the whole tree in `suppressHydrationWarning` and move on
Suppressing the warning hides a real bug: event handlers bound to the wrong tree. - Weak: Turn off SSR; hydration bugs mean SSR is not worth it
SSR is how you ship first paint and SEO. Fix the mismatch; do not throw the tool away. - Red flag: Render a random id on the server so we can 'see' the mismatch
Random server ids guarantee a mismatch. That is a demo of the bug, not a fix.
Who gets asked this
More Frontend questions
- A long profile form is open. The user hits Save and the network is slow. What does the form do?
- Two people edit the same note. The second save returns 409 Conflict. What does the UI do with 409?
- A teammate throws inside `fetch` so the React error boundary can show the outage. What is the difference?
- A burst of autosaves returns 429 from the API gateway. What does the UI do with 429?
- The first screen is a list loaded from `GET /items`. What states does the screen need?
- Saving a profile can fail with a 400 (`email taken`) or a 500. What does the UI show?
- The user submits 'create project'. A teammate wants the new card to appear before the response. When do you…
- The API process is down. The UI still loads. What should the UI do?