AceDevHub
Intermediate React Interview QuestionsIntermediateComparison

React · Question 68

What is the difference between Suspense and an Error Boundary?

Direct answer

Suspense handles content that is temporarily not ready, while an Error Boundary handles supported errors thrown by descendant rendering and displays fallback error UI.

ConcernSuspenseError Boundary
Primary conditionContent is waiting / suspendedDescendant rendering throws an error
Fallback meaningLoading or pending UIFailure UI
Typical pairinglazy or Suspense-enabled dataError recovery/logging boundary
Same thing?NoNo

A lazy import that is still loading is handled by Suspense. If that lazy import's loading promise rejects, the error can be handled by the nearest Error Boundary.