React Query v3 to v4 #3273
-
Hi, The store project has clasess that are exported something like this:
So then we can import them as the following code:
I'm trying to migrate from react-query v3.13.3 to react-query v4.0.0-alpha.9, since we are tying to implement an offline solution. In the current version of React Query (v3.13.3) using the store as a class based modules work perfect. However when we migrated to v4 we are getting this error: After checking at the documention seems we have to export a function with the useQuery or useMutation instead of having them gruoped inside a class. Have the store rewrite to function based will involved a lot of effort, any idea here? we really want to keep it up with React Query . Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
hmm, I think calling generally, there weren't really any changes in this regard between v3 and v4. It looks more like you're maybe having two different versions of react-query so the react context is not picked up? Like maybe your npm package has v4 but the consumer still has v3? does your package have react-query as a peerDependency? |
Beta Was this translation helpful? Give feedback.
hmm, I think calling
loginMFAChallenge.loginUser
, which calls a hook under the hood would violate the rules-of-hooks because hooks have to start withuse...
. So i think purely from a react-hooks perspective, you can't have classes that export hooks.generally, there weren't really any changes in this regard between v3 and v4. It looks more like you're maybe having two different versions of react-query so the react context is not picked up? Like maybe your npm package has v4 but the consumer still has v3? does your package have react-query as a peerDependency?