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

Bug: pageContext.queryClient isn't defined on the client-side #163

Closed
flyerH opened this issue Jul 24, 2024 · 7 comments
Closed

Bug: pageContext.queryClient isn't defined on the client-side #163

flyerH opened this issue Jul 24, 2024 · 7 comments

Comments

@flyerH
Copy link

flyerH commented Jul 24, 2024

4dcb0de073caab49c808e338f2ea651d

This is a mini repo
https://stackblitz.com/edit/vitejs-vite-sysrfj?file=package.json

  1. Add /id such as /1 to the end of the link on the preview page on the right
  2. Click on the hyperlink
@brillout
Copy link
Member

Are you using the latest version of all dependencies? Can you publish the reproduction on GitHub?

@flyerH
Copy link
Author

flyerH commented Jul 25, 2024

Are you using the latest version of all dependencies? Can you publish the reproduction on GitHub?

Yes, I have upgraded to the latest version, this is repo on Github https://github.com/flyerH/vike-vue-example
Run and open http://localhost:3000/1234

@flyerH
Copy link
Author

flyerH commented Jul 25, 2024

And I found this modify can fix problem, but I don't know if it will cause new problem.

// https://github.com/vikejs/vike-vue/blob/main/packages/vike-vue-query/renderer/hydrateVueQuery.ts
- const hydrateVueQuery = ({ queryClient, fromHtmlRenderer, isHydration }) => {
+ const hydrateVueQuery = (params) => {
+   const { fromHtmlRenderer, isHydration } = params;
+   const queryClient = 'queryClient' in params ? params.queryClient : null;
    if (!isHydration) {
        return;
    }
    const { vueQueryInitialState } = fromHtmlRenderer;
    if (!queryClient || !vueQueryInitialState) {
        // happens if SSR is off
        return;
    }
    hydrate(queryClient, vueQueryInitialState);
};

brillout added a commit that referenced this issue Jul 25, 2024
@brillout
Copy link
Member

I went for your fix and pre-released it as [email protected].

Let's see if you still have issues.

(Btw. in case your company is up for it we're looking for sponsors.)

@flyerH
Copy link
Author

flyerH commented Jul 26, 2024

The problem is solved, thanks~

@flyerH
Copy link
Author

flyerH commented Sep 11, 2024

Hello, can you please publish a release version of vike-vue-query?

@brillout
Copy link
Member

Released [email protected].

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