How React Suspense and Error Boundaries interact — and why your UI goes blank
A developer on DEV Community has detailed a subtle but common React bug where wrapping a lazy-loaded component in Suspense outside an Error Boundary can cause neither fallback UI to appear. The issue stems from how React internally handles suspensions and errors differently during its render and commit phases, using a 'lanes' system to prioritize updates. When a component both suspends and throws an error in close proximity, React can prioritize the suspension and skip error handling in that render cycle, resulting in a blank screen. The recommended fix is to place the Suspense boundary inside the Error Boundary, so errors are caught before Suspense attempts to handle any suspensions. Additional edge cases, such as components that suspend first and then throw errors during effects, can still cause UI flickers even with the correct nesting order.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in