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: reconcile
and placeholderData
don't work together
#7173
Comments
Apologies for the delay here. I'll be taking a look at this again this weekend. The reason we made reconcile off by default is because of this exact reason. The immutable nature of the server resources make it very tricky to implement correct reconciliation. The I have been thinking about it this week, and will possibly have an internal solution to this soon which would not need the |
* 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 I'm still having trouble with using If you type something in the input, I think it should appear as current query result, but it doesn't. |
@PeterDraex In React, when rendering a list of JSX elements, each element must have a unique key prop. This key helps React identify which items have changed, are added, or are removed, thus optimizing the rendering process. In contrast, SolidJS handles this differently. Instead of reconciling JSX elements directly via a key, SolidJS uses the For component, which requires a reconcile function to manage the list based on a specific key property, typically id. This approach ensures that the items in the list maintain the same reference, allowing SolidJS to efficiently update the DOM when the data changes. In the example above there is no |
@ardeora I thought that if I call reconcile with no key, it'll still prevent unnecessary updates to DOM. If I load 100 objects without ids and one gets changed, without reconcile all 100 are rerendered, but with reconcile, same value writes are blocked, and only the changed properties of the changed object are rerendered. Is that not true? Also, I had configured |
@PeterDraex Say if there is an array like so array = [
{name: 'John', status: 'inactive'},
{name: 'David', status: 'deactivated'},
{name: 'Dominik', status: 'active'},
{name: 'Peter', status: 'active'},
] Now you refetch the data and the data looks like so array = [
{name: 'John', status: 'inactive'},
{name: 'David', status: 'deactivated'},
{name: 'Dominik', status: 'active'},
{name: 'Aryan', status: 'active'},
{name: 'Peter', status: 'active'},
] What changed here? If we use the I would suggest not setting a global reconcile option for your app. If you see this example in Astro https://github.com/TanStack/query/blob/main/examples/solid/astro/src/components/SolidApp.tsx#L75-L112 You can see that I set two different reconcile keys for the same query! And this makes me keep the same DOM nodes in place while switching between pokemons Instead you should set a reconcile id on a per query basis when required. |
@ardeora Ok, thanks! |
Describe the bug
When using
placeholderData: keepPreviousData
andreconcile
together, the previous data is not kept. Instead, a result of another query is used as placeholder data.Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-bvyrzi?file=src%2FCounter.tsx
Steps to reproduce
Expected behavior
The
data has 3 items
is displayed immediately, as this query is cached.If new data should be loaded, the previous result of
data has 0 items
should be visible while loading.Tanstack Query adapter
solid-query 5.28.6
The text was updated successfully, but these errors were encountered: