I am using React.js to run a simple React Query code but I am facing an error. The code:
import { useQuery } from '@tanstack/react-query';
import Axios from "axios"
export const Home = () => {
const { data } = useQuery(["cat"],() => {
return Axios.get("https://catfact.ninja/fact").then((res) => res.data);
});
return (
<h1>
HOPE <p>{data?.fact}</p>
</h1>
)
}
The code above is using the public catfact api to fetch the 'fact' data and display it on screen.
The error:
Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions.
Please use the error stack to find the culprit call.
More info here:
https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object
useBaseQuery@http://localhost:3000/static/js/bundle.js:42203:13
useQuery@http://localhost:3000/static/js/bundle.js:42265:72
Home@http://localhost:3000/static/js/bundle.js:30:70
renderWithHooks@http://localhost:3000/static/js/bundle.js:20001:31
mountIndeterminateComponent@http://localhost:3000/static/js/bundle.js:23285:17
beginWork@http://localhost:3000/static/js/bundle.js:24581:20
callCallback@http://localhost:3000/static/js/bundle.js:9597:18
invokeGuardedCallbackDev@http://localhost:3000/static/js/bundle.js:9641:20
invokeGuardedCallback@http://localhost:3000/static/js/bundle.js:9698:35
beginWork$1@http://localhost:3000/static/js/bundle.js:29562:32
performUnitOfWork@http://localhost:3000/static/js/bundle.js:28810:16
workLoopSync@http://localhost:3000/static/js/bundle.js:28733:26
renderRootSync@http://localhost:3000/static/js/bundle.js:28706:11
performConcurrentWorkOnRoot@http://localhost:3000/static/js/bundle.js:28101:78
workLoop@http://localhost:3000/static/js/bundle.js:36113:46
flushWork@http://localhost:3000/static/js/bundle.js:36091:18
performWorkUntilDeadline@http://localhost:3000/static/js/bundle.js:36328:25
Your minimal, reproducible example
any react app involving react query
Steps to reproduceData being fetched and displayed
How often does this bug happen?Every time
Screenshots or VideosNo response
PlatformWindows, Linux
Tanstack Query adapterreact-query
TanStack Query versionv5.14.1
TypeScript versionNo response
Additional contextNo response
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4