React › Suspense & Concurrent Rendering
What is Suspense in React and what basic problem does it solve?
BeginnerAnswer
Suspense lets a component tell React that it is not ready yet, such as while data is still loading, and React shows a fallback, like a loading spinner, until it is ready. This gives you a clean, consistent way to handle loading states without manually managing a separate loading flag everywhere.
function ProfilePage() {
return (
<Suspense fallback={<p>Loading profile</p>}>
<ProfileDetails />
</Suspense>
);
}Real-world example A profile page shows a simple loading message while the user's details are being fetched, using Suspense to handle the waiting state cleanly instead of manually tracking a loading variable inside the component.