Вообщем пока я придумал только такое решение:
export const MyPage: React.FC = () => {
const itemsPerPage = 50;
const [searchText, setSearchText] = useState(''),
[activePage, setActivePage] = useState(1),
[filters, setFilters] = useState<Filters>({
status: 'all',
category: '1'
});
const {
data,
isLoading,
isFetching,
isSuccess,
refetch,
} = useSearchItemsQuery(
{
sortBy: sortBy,
startAt: (activePage - 1) * itemsPerPage,
maxResults: itemsPerPage,
searchText,
filters,
},
{ refetchOnFocus: true, pollingInterval: 30000 },
);
// Page loader
const [showPageLoader, setShowPageLoader] = useState(true);
useEffect(() => {
setShowPageLoader(true);
}, [activePage, itemsPerPage, sortBy, filters]);
useEffect(() => {
if (!isFetching) {
setShowPageLoader(false);
}
}, [isFetching]);
return (
<div>
{data && items.map(item => <Item key={item.id} item={item} />)}
<Spinner show={isLoading || (isFetching && showPageLoader) />
</div>
)
}