-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Actual Behavior
Throws error when using useQuery.
Expected Behavior
Will fetch the data properly.
Here's a very simple implementation
Users.jsx
import React from "react";
import { useQuery } from "react-query";
const fetchUsers = async () => {
const response = await fetch("https://jsonplaceholder.typicode.com/users");
return response.json();
};
const Users = () => {
const { data, status } = useQuery("products", fetchUsers);
console.log(data);
return (
<React.Fragment>
<ul>
<li>{/* list of users */}</li>
</ul>
</React.Fragment>
);
};
export default Users;
package.json
"react": "^16.0.0",
"react-query": "^2.5.6",
Environment
Node Version : v14.2.0
Browser
Microsoft Edge: v84.0.522.50
I followed a video tutorial but I wonder why it gives me an error when it's just a simple implementation.
Metadata
Metadata
Assignees
Labels
No labels