What is the difference between useGetQuery() and useLazyGetQuery() in redux toolkit?

Viewed 18

What is the difference between useGetQuery() and useLazyGetQuery() in redux toolkit and when to use them?

1 Answers

According to The Docs:

useLazyQuery

A React hook similar to useQuery, but with manual control over when the data fetching occurs.

usage

const [trigger, result, lastPromiseInfo] =
  api.endpoints.getPosts.useLazyQuery(options)
// or
const [trigger, result, lastPromiseInfo] = api.useLazyGetPostsQuery(options)
Related