Skip to content

Commit

Permalink
fix(solid-query): Hydrate correct queryKey on hydration (#7174)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardeora committed Mar 26, 2024
1 parent 262794f commit c98a02a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/solid-query/src/createBaseQuery.ts
Expand Up @@ -138,6 +138,7 @@ export function createBaseQuery<
}
return defaultOptions
})
const initialOptions = defaultedOptions()

const [observer, setObserver] = createSignal(
new Observer(client(), defaultedOptions()),
Expand Down Expand Up @@ -254,13 +255,12 @@ export function createBaseQuery<
* Note that this is only invoked on the client, for queries that were originally run on the server.
*/
onHydrated(_k, info) {
const defaultOptions = defaultedOptions()
if (info.value) {
hydrate(client(), {
queries: [
{
queryKey: defaultOptions.queryKey,
queryHash: defaultOptions.queryHash,
queryKey: initialOptions.queryKey,
queryHash: initialOptions.queryHash,
state: info.value,
},
],
Expand All @@ -272,8 +272,8 @@ export function createBaseQuery<
* Do not refetch query on mount if query was fetched on server,
* even if `staleTime` is not set.
*/
const newOptions = { ...defaultOptions }
if (defaultOptions.staleTime || !defaultOptions.initialData) {
const newOptions = { ...initialOptions }
if (initialOptions.staleTime || !initialOptions.initialData) {
newOptions.refetchOnMount = false
}
// Setting the options as an immutable object to prevent
Expand Down

0 comments on commit c98a02a

Please sign in to comment.