All jobs / Full-stack developer / Frontend
Full-stack developer interview question · 3–5 years
A teammate throws inside `fetch` so the React error boundary can show the outage.
What is the difference?
The strongest answer
An error boundary catches render throws; a failed fetch is data you must handle in the request path — do not throw in the fetch to 'reuse' the boundary for an API 500
Why it works
Exactly. Boundaries are for unexpected render failures. A 500 is an expected state of a request. Mixing them turns every outage into a white screen.
What a good answer covers
- Boundary = render/unknown.
- Fetch = loading/error/data.
- Do not throw on HTTP to be 'clever'.
- Keep the rest of the page alive.
Answers that fall short
- Close, but not the strongest: One boundary around the app is enough for both
A root boundary that also eats API errors gives you one ugly fallback for a missing comma and a down payment service. - Weak: A failed fetch should crash the tree so we notice
Crashing the tree on a 500 is punishing the rest of the page that still works. - Red flag: Disable boundaries; they hide bugs from QA
Boundaries hide nothing if you report them. They stop a blank tab.
Who gets asked this
More Frontend questions
- 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?
- A Next-style SSR page flashes and React logs a hydration mismatch on the header. What do you fix first?
- 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?