What is React Suspense and how do you use it?
Instruction: Describe the purpose of React Suspense and provide an example of how it can be used for data fetching.
Context: This question tests the candidate's knowledge of React's capabilities for handling asynchronous operations and improving user experience during data loading.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Suspense shows a fallback when a supported descendant suspends. An Effect that fetches data does not suspend merely because it is inside a boundary. A supported framework integration or reading a stable promise with use can connect loading to Suspense; failures need an error boundary.
This React 19+ browser entry fetches once outside rendering and reuses the same promise...