0
6
JRJose Romero
apolloreacthookβ’β’β’
React TypeScript RecipesExample usage of the useQuery hook from Apollo in React.
Here data
is an object containing the results of the query, error
is an object if there was an error while trying to get the data, or undefined
if everything went well. loading
is a boolean indicating whether the server is currently loading the query's data or not.
Library: react
Shortcut: apollo.hook.query.use
import { useQuery } from '@apollo/client';
const { data, error, loading } = useQuery<ResponseType, VariableType>(GRAPHQL_QUERY,
{
variables: { variables }
});