Our great sponsors
-
TanStack Query
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
https://github.com/vercel/swr/blob/14956a840ac9b75fe321bf846...
so if I check `isLoading` in my component then typescript isn't able to narrow/refine the type to something more specific since it isn't a sum type.
While with react-query, it's a proper sum type that can be differentiated by checking `isLoading`.
The type is actually quite long so here's just a bit
export type QueryObserverResult =
https://github.com/TanStack/query/blob/9b21609350d9ad41faf5c...
The key point in the type above is `isLoading: true` and `data: undefined`, which means if I check `isLoading === true`, then typescript knows the data is not available.
SWR doesn't provide these guarantees.