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

Next, useQuery e monorepo #1

Open
ayrtonlacerda opened this issue Aug 15, 2024 · 1 comment
Open

Next, useQuery e monorepo #1

ayrtonlacerda opened this issue Aug 15, 2024 · 1 comment

Comments

@ayrtonlacerda
Copy link
Owner

No description provided.

@ayrtonlacerda
Copy link
Owner Author

ayrtonlacerda commented Aug 15, 2024

Error

 ⨯ ../src/QueryClientProvider.tsx (18:11) @ useQueryClient
 ⨯ Error: No QueryClient set, use QueryClientProvider to set one
    at useLoginMutation (../project-common/dist/services/auth/login.js:12:60)
    at Home (./src/app/auth/login/page.tsx:27:134)
digest: "2381507887"
  16 |
  17 |   if (!client) {
> 18 |     throw new Error('No QueryClient set, use QueryClientProvider to set one')
     |           ^
  19 |   }
  20 |
  21 |   return client
 GET /_next/static/chunks/app/auth/login/chunk-5WQ4PXEV.mjs.map 404 in 7436ms
 GET /auth/login 500 in 1627ms

solution

React-query V4 update:

webpack: (config, options) => {
      if (options.isServer) {
        config.externals = ['@tanstack/react-query', ...config.externals]
      }
      config.resolve.alias['@tanstack/react-query'] = path.resolve(
        require.resolve('@tanstack/react-query'),
        '../../../'
      )
      return config
    }

This worked for us! But since our next.config.js is at the root, we didn't have to add the path traversing.

Originally posted by @bombillazo in TanStack/query#3595 (comment)

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

1 participant