-
-
Notifications
You must be signed in to change notification settings - Fork 46
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] @zodios/react with nextjs: No QueryClient set #191
Comments
Update with a CRA example on codesandbox. Sorry I can only track the problem this far. |
Have you tried using Hydrate component from react query? |
Not sure what is that mean.
|
Hello @QzCurious , Thanks for taking the time to report this issue. So the fix is to update webpack config of next-js to instruct it to instanciate const path = require("path");
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
webpack: (config, options) => {
if (options.isServer) {
config.externals = ["@tanstack/react-query", ...config.externals];
}
const reactQuery = path.resolve(require.resolve("@tanstack/react-query"));
config.resolve.alias["@tanstack/react-query"] = reactQuery;
return config;
},
};
module.exports = nextConfig; I tested it and it works for now. i'll check with dominik the maintainer of react-query if he thinks that's fixable on |
I'll update the docs of zodios and nextjs example and add a tip for configuring webpack with this workaround in the mean time. |
updated example : https://github.com/ecyrbe/zodios-express/tree/main/examples/next update on zodios website docs incoming |
Thank you for always replying back, even solving, issues very soon. But I get lost in what esm, commonjs, webpack things are about. I'll try the workaround for now. |
I now can confirm the bug is related to esm with |
@QzCurious yes you can report any issues with the workaround. but you don't need to revert to |
created a bug on |
Closing since i updated the documentation. Not much else i can do as even with esm build just created it still needs the workaround. |
For reference, the workaround is documented here. |
@QzCurious I finally found how to fix this on zodios packaging. I needed to had exports that are interpreted by webpack. This is now working without the workaround on :
|
Cool, congratulations 🎉 |
Steps to reproduce:
yarn
yarn dev
apiHook.useUser()
produce the errorIt's just a simple nextjs project installed with necessary dependencies of @zodios/react. It might be easier to inspect this demo by checking what each commit does instead of reviewing whole project.
Side note: The same setup working fine with CRA on codesandbox here.
The text was updated successfully, but these errors were encountered: