Skip to content

Instantly share code, notes, and snippets.

Last active Oct 21, 2021
What would you like to do?
Just a gist to explain React Query
function ProductList() {
const getProducts = async () => {
const res = await fetch("");
const products = await res.json();
return products;
const { data, isLoading, isError, error } = useQuery("productList", getProducts);
if (isLoading) return "Loading...";
if (isError) return "An error has occurred: " + error.message;
return (
<p>$ {data.price}</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment