1

I'm using redux toolkit RTK with multiple hooks inside one single component, but the issue is that they are running together even I'm using the params skip which I dont want it in this case, here is my code:

const { data, isFetching } = useGetTestsQuery(filters, {
    pollingInterval: 5000
});

const {
    data: testsByStatus,
    isFetching: fetchDataByStatus
} = useGetTestsByStatusQuery(filters, {
    pollingInterval: 5000,
    skip: data
});
return <Table columns={columns} dataSource={data || testsByStatus} />;

in network tab I can see that both requests are running in same time, can I prevent eg. useGetTestsByStatusQuery from fetching while there are some data in useGetTestsQuery or vice-versa ?

Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43
Errand
  • 51
  • 5

1 Answers1

1

Right now you are skipping if there is data and not skipping if there is no data.

You probably want to do

useGetTestsByStatusQuery(filters, {
    pollingInterval: 5000,
    skip: !data
});
phry
  • 35,762
  • 5
  • 67
  • 81