7

I am refactoring a piece of code and it shows this type of error whenever I try to import "react-query

1
  • Please provide enough code so others can better understand or reproduce the problem. Commented Aug 2, 2022 at 15:10

3 Answers 3

9

I ran into the same thing and had to downgrade to version 3.

npm i react-query@3

Or for 4+

npm i @tanstack/react-query
Sign up to request clarification or add additional context in comments.

1 Comment

Alright this actually solved my problem. I have to install a downgraded version of react-query
6

It's because you are importing into a TypeScript file and it can't find the type declaration for the imported module. Normally all you need to do is to follow the given instructions and open a command prompt, go to the directory D:\overview and type:

npm i --save-dev @types/react-query

2 Comments

I tried this solution which you have suggested but it is not working
Because no such type dependency exists. This answer is wrong.
5

react-query was renamed to @tanstack/react-query in v4. You need to rename all your imports from react-query to @tanstack/react-query.

You don't need to install @types/react-query. v4 is already written in typescript.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.