3 ms·
And suspense is the worst thing to happen to React
by bevacqua 5y ago
And suspense is the worst thing to happen to React
- scotty79 5y agoWhy is that? It's a feature I was missing in react nearly from the strart and I was trying many times to mimic it with varying degree of success but all attempts were finicky.
- bevacqua 5y agoit optimizes for not thinking about loading states, and the way it's normally used (hook fetches data, suspends) results in you having to go out of your way to add a loading state near the component that suspended, as you have to create an intermediate component and a loading component, splitting what should be a single concern into several, and it results in a lot of duplication that previously could be addressed by just having an `isLoading` prop not thinking about loading states hurts ux and perceived performance edit to clarify: i like hooks (though people abuse them) and believe react has generally always been best-in-class at thoughtful interface design. suspense breaks with that imo
- tuan 5y ago>> add a loading state near the component that suspended, as you have to create an intermediate component and a loading component, splitting what should be a single concern into several I'm not following. Can you just wrap the component that suspends with <Suspense fallback={SharedLoadingUI} /> ? The SharedLoadingUI could help with duplication right ?
- kall 5y agoLoading Boundary type things do have that issue, but the part where you can delay any update for the 70ms your very fast API response takes, while showing an inline loading indicator, is a real UX win.