An Introduction to React Suspense
You might have been hearing about Suspense
for a while now and it isn't a relatively new feature as it shipped with React 16.6 but you just might not have gotten into it. No worries, I'm going to explain what Suspense is exactly.
First I wanna distinguish we have Suspense with code splitting and Suspense for data fetching (experimental). In this article, i'm going to explain the general concept around suspense.
Suspense means we suspend rendering our component till some condition is met. Think of it like this: "do not render X thing until some condition is met". Typically, we pass a prop fallback
to suspense which is what will be rendered while waiting for the condition to be met.
In my next article titled What is code splitting and why do we need it in our React apps ? i'll show you how to use Suspense for code splitting in your react apps.
What is code splitting and why do we need it in our React apps?