Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
Redux Toolkit RTK Query - Difference between useGetDomainsQuery VS api.endpoints.getDomains.initiate(args)

I want to make an API call with some params, and use the selectors to get that values in my components I am getting data in below implementation

const { data, isLoading, isFetching, error } = useGetDomainsQuery({
    search: search || '',
    status: status || '',
    page_number: pageNo,
    page_size: pageRow,
  });

whereas, I am not getting data in selector

dispatch(
    api.endpoints.getDomains.initiate({
      search: search || '',
      status: status || '',
      page_number: pageNo,
      page_size: pageRow,
    }),
  ); 

Selector:-

export const selectDomainsResult = api.endpoints.getDomains.select();

const selectDomainsData = createSelector(
  selectDomainsResult,
  (domainsResult) => domainsResult.data, 
);


export const {
  selectAll: selectAllDomains,
  selectById: selectDomainById,
  selectIds: selectDomainIds,
} = domainsAdapter.getSelectors(
  (state) =>
     selectDomainsData(state) ?? initialState,
);

and using my selector like this

const domains = useSelector(selectAllDomains);

this implementation always gets uninitialised and returns empty array users: []

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The selector you have created with api.endpoints.getDomains.select() will give you the cache entry for calling initiate() or initiate(undefined) but not initiate(something) - for that you would have to use select(something).

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!