Reputation: 13
Unexpected Application 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
import { useQuery } from "@tanstack/react-query";
const AllUsers = () => {
const {data: users = [], refetch} = useQuery(['users'], async() => {
const res = await fetch('http://localhost:5000/users')
return res.json();
})
return (
<div>
{users.length}
</div>
);
};
export default AllUsers;
Upvotes: 1
Views: 1799
Reputation: 11
// I have this problem; The solution to this problem;
const { data: users = [], refetch } = useQuery({
queryKey: ["users"],
queryFn: async () => {
const res = await fetch("http://localhost:5000/users");
return res.json();
}, });
return <div>{users.length} </div>;
Upvotes: -1
Reputation: 83
try to send parameter in an object format. Example:
const {data: users = [], refetch} = useQuery({queryKey:['users'], queryFn: async() => {
const res = await fetch('http://localhost:5000/users')
return res.json();
})
return (
<div>
{users.length}
</div>
);
Upvotes: 0