Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solid-query] Using data in a show causes double-rendering after a transition #7036

Closed
Brendonovich opened this issue Mar 6, 2024 · 1 comment

Comments

@Brendonovich
Copy link
Contributor

Brendonovich commented Mar 6, 2024

Describe the bug

This might be a bug in Solid itself, but when passing a query's data to a <Show> with a function child, the child gets ran multiple times without being cleaned up properly, resulting in the child being rendered twice. This requires that the component be mounted during a transition.

Your minimal, reproducible example

https://stackblitz.com/edit/solidjs-templates-ydv3gm?file=src%2FApp.tsx

Steps to reproduce

  1. Load the stackblitz
  2. Click the 'two' link to navigate to /two
  3. Once the transition is complete, there are 2 breadcrumbs rendered via a portal within the <Show> rather than just one
  4. Navigate back to /, reload the page, and repeat after commenting out the TSQ Page2 in favour of the raw resource
  5. Observe only one breadcrumb being rendered

Expected behavior

I'd expect only one breadcrumb to be rendered at all times.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Brave
  • Version: 1.63.162

Tanstack Query adapter

solid-query

TanStack Query version

5.25.0

TypeScript version

No response

Additional context

@ardeora since this is a solid problem.
Again, it's entirely possible this is a bug in Solid since there's no reason that <Show> should forget to cleanup, whether rendered during a transition or not.
Also it could be to do with the combination of Show + transition + Portal + TSQ

ardeora added a commit that referenced this issue Apr 13, 2024
* feat(solid-query): Rework internals of createBaseQuery

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 
#6373
PRs for which are coming soon.

A key few highlights coming with this change:
1. Removal of `mutate` and `refetch` branches in `createClientSubscriber`: We had two different ways of resolving a query resource. The `mutate` option that optimistically updated a resource proved to be a problem with error queries. A query that has `placeholder` data and fails for any reason would see a flash of blank content before yielding to the ErrorBoundary. Using `refetch` for all query resolutions gives us a nice and simple way to transition to error boundaries
2. Removal of batched calls with `notifyManager`: With the new approach we dont need to batch anything. Everything is taken care of automatically. This removes all sideEffects from solid-query as a nice plus
3. Central place to update state: The new `setStateWithReconciliation` function provides a nice and easy way to make the `reconcile` option way more powerful
4. Only accessing the `data` property now would trigger Suspense boundary. Previously any property accessed on a query would trigger the suspense boundary. This was not intentional and has been fixed now
5. Proxied `data` doesn't jump between different values in most cases
@ardeora
Copy link
Contributor

ardeora commented Apr 13, 2024

This issue has now been fixed in v5.30.0. Repro here! https://stackblitz.com/edit/solidjs-templates-ern4v6?file=src%2FApp.tsx

@ardeora ardeora closed this as completed Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants