In React, needless complexity and repeated null checks can often be...


In React, needless complexity and repeated null checks can often be eliminated via one simple pattern:

Return early when loading. Render *one* loading spinner until all fetch calls are complete.

Benefits:
1. The user doesn’t see a bunch of layout shift caused by multiple…

Note: This is a tradeoff.

The risk: If one query is slow, the user sees a loader until all complete.

My rule: If all query results are necessary for the user to do anything useful, I use one spinner.

If the user can get started with partial data, I consider multiple spinners.

View original on X