Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to ReactQuery v5 #1321

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
default error type
tom2drum committed Nov 1, 2023
commit 840d4b6cda59a3ffb4d56da20382990947f0cfbe
2 changes: 1 addition & 1 deletion lib/api/useQueryClientConfig.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export default function useQueryClientConfig() {
}
return failureCount < 2;
},
useErrorBoundary: (error) => {
throwOnError: (error) => {
const status = getErrorObjStatusCode(error);
// don't catch error for "Too many requests" response
return status === 429;
3 changes: 2 additions & 1 deletion ui/address/coinBalance/AddressCoinBalanceHistory.tsx
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import type { AddressCoinBalanceHistoryResponse } from 'types/api/address';
import type { PaginationParams } from 'ui/shared/pagination/types';

import config from 'configs/app';
import type { ResourceError } from 'lib/api/resources';
import ActionBar from 'ui/shared/ActionBar';
import DataListDisplay from 'ui/shared/DataListDisplay';
import Pagination from 'ui/shared/pagination/Pagination';
@@ -15,7 +16,7 @@ import AddressCoinBalanceListItem from './AddressCoinBalanceListItem';
import AddressCoinBalanceTableItem from './AddressCoinBalanceTableItem';

interface Props {
query: UseQueryResult<AddressCoinBalanceHistoryResponse> & {
query: UseQueryResult<AddressCoinBalanceHistoryResponse, ResourceError<unknown>> & {
pagination: PaginationParams;
};
}
3 changes: 2 additions & 1 deletion ui/address/details/AddressCounterItem.tsx
Original file line number Diff line number Diff line change
@@ -7,11 +7,12 @@ import type { AddressCounters } from 'types/api/address';

import { route } from 'nextjs-routes';

import type { ResourceError } from 'lib/api/resources';
import LinkInternal from 'ui/shared/LinkInternal';

interface Props {
prop: keyof AddressCounters;
query: UseQueryResult<AddressCounters>;
query: UseQueryResult<AddressCounters, ResourceError<unknown>>;
address: string;
onClick: () => void;
isAddressQueryLoading: boolean;
3 changes: 2 additions & 1 deletion ui/home/indicators/ChainIndicatorItem.tsx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import React from 'react';
import type { HomeStats } from 'types/api/stats';
import type { ChainIndicatorId } from 'types/homepage';

import type { ResourceError } from 'lib/api/resources';
import useIsMobile from 'lib/hooks/useIsMobile';

interface Props {
@@ -14,7 +15,7 @@ interface Props {
icon: React.ReactNode;
isSelected: boolean;
onClick: (id: ChainIndicatorId) => void;
stats: UseQueryResult<HomeStats>;
stats: UseQueryResult<HomeStats, ResourceError<unknown>>;
}

const ChainIndicatorItem = ({ id, title, value, icon, isSelected, onClick, stats }: Props) => {
3 changes: 2 additions & 1 deletion ui/token/TokenDetails.tsx
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import { scroller } from 'react-scroll';

import type { TokenInfo } from 'types/api/token';

import type { ResourceError } from 'lib/api/resources';
import useApiQuery from 'lib/api/useApiQuery';
import getCurrencyValue from 'lib/getCurrencyValue';
import { TOKEN_COUNTERS } from 'stubs/token';
@@ -18,7 +19,7 @@ import TruncatedValue from 'ui/shared/TruncatedValue';
import TokenNftMarketplaces from './TokenNftMarketplaces';

interface Props {
tokenQuery: UseQueryResult<TokenInfo>;
tokenQuery: UseQueryResult<TokenInfo, ResourceError<unknown>>;
}

const TokenDetails = ({ tokenQuery }: Props) => {
3 changes: 2 additions & 1 deletion ui/token/TokenVerifiedInfo.tsx
Original file line number Diff line number Diff line change
@@ -5,12 +5,13 @@ import React from 'react';
import type { TokenVerifiedInfo as TTokenVerifiedInfo } from 'types/api/token';

import config from 'configs/app';
import type { ResourceError } from 'lib/api/resources';
import LinkExternal from 'ui/shared/LinkExternal';

import TokenProjectInfo from './TokenProjectInfo';

interface Props {
verifiedInfoQuery: UseQueryResult<TTokenVerifiedInfo>;
verifiedInfoQuery: UseQueryResult<TTokenVerifiedInfo, ResourceError<unknown>>;
}

const TokenVerifiedInfo = ({ verifiedInfoQuery }: Props) => {
5 changes: 3 additions & 2 deletions ui/txs/useTxsSort.tsx
Original file line number Diff line number Diff line change
@@ -4,17 +4,18 @@ import React from 'react';
import type { TxsResponse } from 'types/api/transaction';
import type { Sort } from 'types/client/txs-sort';

import type { ResourceError } from 'lib/api/resources';
import * as cookies from 'lib/cookies';
import sortTxs from 'lib/tx/sortTxs';

type HookResult = UseQueryResult<TxsResponse> & {
type HookResult = UseQueryResult<TxsResponse, ResourceError<unknown>> & {
sorting: Sort;
setSortByField: (field: 'val' | 'fee') => () => void;
setSortByValue: (value: Sort | undefined) => void;
}

export default function useTxsSort(
queryResult: UseQueryResult<TxsResponse>,
queryResult: UseQueryResult<TxsResponse, ResourceError<unknown>>,
): HookResult {

const [ sorting, setSorting ] = React.useState<Sort>(cookies.get(cookies.NAMES.TXS_SORT) as Sort);