Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Created July 6, 2020 15:14
Show Gist options
  • Save coryhouse/d08da6b72e40902301fe1192ca0789c0 to your computer and use it in GitHub Desktop.
Save coryhouse/d08da6b72e40902301fe1192ca0789c0 to your computer and use it in GitHub Desktop.
import React from "react";
import { getUsers } from "./services/userService";
import { useQuery } from "react-query";
export default function ReactQueryDemo() {
const { data, isLoading, error } = useQuery("users", getUsers);
if (isLoading) return "Loading...";
if (error) return "Oops!";
return data[0].username;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment