Module '"@tanstack/react-query"' has no exported member 'QueryClient'

See original GitHub issue

Describe the bug

When trying to import QueryClient, TypeScript says that @tanstack/react-query doesn’t export QueryClient. The QuickStart guide clearly mentiones that QueryClient needs to be imported (https://tanstack.com/query/v4/docs/quick-start).

Your minimal, reproducible example

It’s just one line: import { QueryClient } from "@tanstack/react-query";

Steps to reproduce

  1. Install @tanstack/react-query
  2. Try to import QueryClient

Expected behavior

QueryClient should be available

How often does this bug happen?

Every time

Screenshots or Videos

image

Type error: Module '"@tanstack/react-query"' has no exported member 'QueryClient'.

  3 | import { Fragment, useState } from "react";
  4 | import Head from "next/head";
> 5 | import { QueryClient } from "@tanstack/react-query";
    |          ^
  6 | 
  7 | function MyApp({ Component, pageProps }: AppProps) {
  8 |   // const [ queryClient ] = useState(() => new QueryClient());

Platform

Every platform

react-query version

4.0.3

TypeScript version

4.7.4

Additional context

Why are there so many problems regarding TypeScript? Yesterday I couldn’t use react-query either, because the typings weren’t exported. How can I be confident that no more issues occur, when two massive oversights regarding TypeScript already happend?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Patchrikcommented, Jul 21, 2022

Alright I finally found the issue. My co worker had also installed react-query that I missed when reading through the project’s packages. So I had a new and old version on the project, versions 4.0.0 & 4.0.8. I removed both of them from the lock, packages, and node modules did a fresh install and everything is now working as it should.

Thank you for your help!

1reaction
maaptehcommented, Jul 21, 2022

For me it was fixed eventually, i first removed react-query (we used beta v4) from my package.json then did a yarn, after that i runned yarn add @tanstack/react-query which installed version 4.0.10 and all my typing errors where gone

Read more comments on GitHub >

github_iconTop Results From Across the Web

[@types/react-query] queryCache is not exported #198 - GitHub
Hi, I am trying react-query with create-react-app (template typescript) and got following error Module '".
Read more >
Typescript module has no exported members - react
I have a strange situation where after some changes one of the modules has stopped exporting its members. The folder structure is: src...
Read more >
Module '"mongoose"' has no exported member ... - YouTube
In this video, we fix an error related to DocumentDefinition and update service inputs so they do not need to omit values.This video...
Read more >
Module '"@microsoft/sp-http"' has no exported member ...
Hi, I am trying to use SPHttpClientBatch class and I am getting the error: Module '"@microsoft/sp-http"' has no exported member ...
Read more >
Module '"react"' has no exported member 'useDeferredValue'.
Module '"react"' has no exported member 'useDeferredValue'. For some reason, I can't seem to use React 18 features in my react application?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found