React Suspense hook sugar for fetching data concurrently.
Why this needed?
React suspense implementations is that catches a thrown promise in suspense tree. See useSWR and react-query. This blocks next hook till previous promise done if you don't prefetch.
suspenseAll
allows us to work concurrently.
Simply, you can think it's React hook version of Promise.all
.
This also obey the Rules of Hooks conceptullay.
I think this is not the answer for parallel work, but it's attempt to solve problem at this moment. I believe in React team will make better interface for Suspense.
If you use ESLint and rules-of-hooks
rule, there's no good options. You should write // eslint-disable-next-line react-hooks/rules-of-hooks
or turn off the rule.