T
TanStack2y ago
sunny-green

accessing the queries status triggers <Suspense>?

Hi, Using the latest solid-query and got a question regarding its interaction with suspense: Stackblitz repro: https://stackblitz.com/edit/solid-vite-6v3qxx?file=src%2Findex.tsx Basically: How does solid-query interact with suspense boundaries of solid-js. In this example i am accessing the queries "fetchStatus" which also seems to trigger the <suspense> boundary above. I've set the "keepPreviousData" as placeholderdata (as per suggesstion in the upgrade-docks). If that is not done, both bondaries trigger. How can i achieve not triggering the suspense? Basic setup i want to do is a searchinput with loading indicator where the results are shown below it. But i'm struggeling as everything seems to trigger the suspense ☹️ Pseudo setup:
<searchinput>
<Show when={query.isLoading}><LoadingIndicator></Show>
<Suspense>
<Show when={query.data}>
{query.data.results}
</Show>
</Suspense>
<searchinput>
<Show when={query.isLoading}><LoadingIndicator></Show>
<Suspense>
<Show when={query.data}>
{query.data.results}
</Show>
</Suspense>
Any Help would be appreciated
KamehamehaNudel
StackBlitz
solid query (forked) - StackBlitz
Starter project for Node.js
7 Replies
like-gold
like-gold2y ago
Hi @KamehamehaNudel, If you access the query within a Suspense boundary, currently there is no way to prevent it from being triggered while data is loading. A discussion has developed in this PR. You can contribute, upvote/suggest what you think would be a good solution. https://github.com/TanStack/query/pull/6415#issuecomment-2012138289 I would show the indicator this way:
<Suspense><Show when={query.isFetching && (query.isPlaceholderData || !query.data)}><LoadingIndicator></Show></Suspense>
<Suspense><Show when={query.isFetching && (query.isPlaceholderData || !query.data)}><LoadingIndicator></Show></Suspense>
GitHub
fix(solid-query): respect suspense: false by aadito123 · Pull Reque...
As of now, the default in solid-query is to suspend when accessing inside a suspense boundary. This may not always be ideal, hence the suspense option is provided. However, that option was not resp...
sunny-green
sunny-greenOP2y ago
@Peter oh right. Thanks for the info. Didnt check the open issues. That last suggestion actually sounds exactly like how i expected it to work. I believe it even did in v4 😅 Thanks for the suggestion, thats for sure a work around
other-emerald
other-emerald2y ago
This PR has been open for a while. It seems quite a few people have this issue yet there has been no comment on it by the maintainers. Maybe I will make another PR implementing the behaviour outlined in the last comment. Hopefully that will get us some closure on whether or not they consider this an issue.
sunny-green
sunny-greenOP2y ago
That would be great to be honest. It’s been very annoying to work around it
like-gold
like-gold17mo ago
GitHub
feat(solid-query): Rework internals of createBaseQuery by ardeora ·...
This change aims to simplify and enhance the internals of createBaseQuery. This change is a precursor to fix a couple of pressing issues in solid-query mentioned in #7079 #7083 #7173 #7036 #6620 #6...
sunny-green
sunny-greenOP17mo ago
Noice Good t know it wasn’t intentional
fascinating-indigo
fascinating-indigo17mo ago
Hello! I jotted down some concerns I have about supporting the suspense false flag here. https://github.com/TanStack/query/pull/6415#issuecomment-2054120162 Would love any feedback 😄 Also happy weekend!
GitHub
fix(solid-query): respect suspense: false by aadito123 · Pull Reque...
As of now, the default in solid-query is to suspend when accessing inside a suspense boundary. This may not always be ideal, hence the suspense option is provided. However, that option was not resp...

Did you find this page helpful?