In most apps I've worked with, either (1) or (2) doesn't hold.
(1) The child is in control of the spinner:
<Parent>
<Child />
</Parent>
Child() {
if (!data) {
return <Spinner />
}
return <Data />
}
(2) The parent is in control of the data <Parent>
{ state.data
? <Child data={data} />
: <Spinner />
}
</Parent>
With Suspense, the child fetches its own data, but the parent is in control of the spinner: <Parent>
<Suspense fallback={<Spinner />}>
<Child />
</Suspense>
</Parent>
So the Child doesn't need to know the details of how the parent app wants to deal delays.Suspense then seems to make it easier to parallelize the data requests, and have a spinner at the lowest parent with a child waiting for data.
I think going all on on components is very easy to reason about. Same direction React Router went with component based routing making it very easy to for example have:
- logged in user portal - catch all errors and show a fallback UI - lazy load child components by routes with fallback loader UI - use a loader fallback potentially for data dependency too.
I mean, it's not perfect and I can see issues people are mentioning, but it feels pretty good to develop with.
Add to this styled components and everything is so component based it's really nice. One main paradigm for the whole front-end.
I don't think it's the best thing ever, but I've enjoyed the newer approaches when working with them.