skip to Main Content

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;

2

Answers


  1. 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>
        );
    
    Login or Signup to reply.
  2. // 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>;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search