function Todos() {
const { isLoading, isError, data, error } = useQuery('todos', fetchTodoList);
if (isLoading) return <span>Loading...</span>
if (isError) return <span>Error: {error.message}</span>
// We can assume by this point that `isSuccess === true`
return (
<ul>
{data.map((todo) => (
<li key={todo.id}>{todo.title}</li>
))}
</ul>
);
}
fresh
: 신선한 상태일 때 refetch 하지 않는다.stale
: 신선하지 않은 상태일 때 아래의 경우에 refetch 한다.Active
- New instances of the query mount
- The window is refocused
- The network is reconnected.
- The query is optionally configured with a refetch interval.
staleTime
cacheTime
isLoading
isFetching