All jobs / Frontend / web developer / React
Frontend / web developer interview question · 3–5 years
A lazy route flashes a blank screen, then an error. How do you structure Suspense and error boundaries?
The strongest answer
Put an error boundary around (or above) Suspense, use route-level fallbacks, and don't let one widget blank the shell
Why it works
Suspense handles wait; error boundaries handle throw. Nested fallbacks keep the chrome up.
What a good answer covers
- Pair wait and failure.
- Error boundary + Suspense at the route.
- Local fallbacks for widgets.
- Keep the app shell mounted.
Answers that fall short
- Close, but not the strongest: Suspense only, no error boundary
A lazy import that fails becomes an uncaught render error without a boundary. - Weak: One spinner for the entire app
A root spinner hides which part is slow. - Red flag: Throw from the fallback to 'retry'
Throwing in the fallback is a loop.
Who gets asked this
More React questions
- What is JSX, and what does the browser actually receive?
- What is the difference between props and state?
- What does useState return, and why must you call the setter instead of assigning?
- Why does React warn about a missing key when you render a list?
- What is a controlled input?
- What is useEffect for?
- What happens if useEffect has an empty dependency array, and if it has none at all?
- How do you render something only when a condition holds?