添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
细心的汤圆  ·  createElement – React ...·  1 周前    · 
飘逸的野马  ·  useInsertionEffect – ...·  1 周前    · 
苦恼的馒头  ·  React TreeSelect ...·  11 小时前    · 
沉着的回锅肉  ·  Docker逃逸系列5 ...·  5 月前    · 
完美的莴苣  ·  vue-element-admin下使用vu ...·  6 月前    · 
斯文的皮带  ·  Support·  10 月前    · 

So I am a big dumb dumb. I have a couple of projects all using react-query, and some using @tanstack/react-query.

On one of those I encountered those errors, and here's the code.

"use client";
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";
import React from "react";
interface RootClientComponentProps {
	children: React.ReactNode;
// This makes sure this component and its children are rendered on the client-side
export default function RootClientProvider({ children }: RootClientComponentProps) {
	const queryClient = new QueryClient();
	return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;

And here's where I'm using the useQuery .

import {useQuery} from "react-query";
const { data } = useQuery({
   queryKey: ["yadayada"],
   queryFn: async () => {
      whatever();
});

Notice the error?

It's basically because on one side I'm importing as

import {QueryClient, QueryClientProvider} from "@tanstack/react-query";

While the other is:

import {useQuery} from "react-query";

If your project uses one or the other, pick one and use it, don't mix two imports. If you're working with the newest version, just import everything from @tanstack/react-query .

That is it.


Like what you see? Check out my projects and my youtube channel , or give me a thanks on Twitter .