diff --git a/.eslintrc.js b/.eslintrc.js index f1de3e49d..4bb0667e2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,27 +1,27 @@ -module.exports = { - extends: [ - "plugin:react-hooks/recommended", - "plugin:@next/next/recommended", - "plugin:storybook/recommended" - ], - plugins: ['react', 'react-hooks'], - parser: '@typescript-eslint/parser', - parserOptions: { - project: './tsconfig.json', - }, - env: { - browser: true, - node: true, - es6: true, - }, - globals: { - page: true, - browser: true, - context: true, - jestPuppeteer: true, - }, - rules: { - 'react-hooks/rules-of-hooks': 'error', - }, - ignorePatterns: ['next.config.js'], -}; +module.exports = { + extends: [ + 'plugin:react-hooks/recommended', + 'plugin:@next/next/recommended', + 'plugin:storybook/recommended', + ], + plugins: ['react', 'react-hooks'], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json', + }, + env: { + browser: true, + node: true, + es6: true, + }, + globals: { + page: true, + browser: true, + context: true, + jestPuppeteer: true, + }, + rules: { + 'react-hooks/rules-of-hooks': 'error', + }, + ignorePatterns: ['next.config.js'], +}; diff --git a/src/app/address/[principal]/StxBalance/BalanceItem.tsx b/src/app/address/[principal]/StxBalance/BalanceItem.tsx index 9b67eb437..e95eac409 100644 --- a/src/app/address/[principal]/StxBalance/BalanceItem.tsx +++ b/src/app/address/[principal]/StxBalance/BalanceItem.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; -import { useSuspenseStxPrice } from '../../../../common/queries/useCurrentPrices'; +import { useStxPrice } from '../../../../common/queries/useCurrentPrices'; import { formatStacksAmount, getLocaleDecimalSeparator, @@ -13,7 +13,7 @@ import { Text } from '../../../../ui/Text'; import { ExplorerErrorBoundary } from '../../../_components/ErrorBoundary'; function UsdBalanceBase({ balance }: { balance: number }) { - const { data: stxPrice } = useSuspenseStxPrice(); + const { data: stxPrice } = useStxPrice(); const usdBalance = getUsdValue(balance, stxPrice); if (!usdBalance) { diff --git a/src/app/signers/consts.ts b/src/app/signers/consts.ts index 688b231eb..e288a559e 100644 --- a/src/app/signers/consts.ts +++ b/src/app/signers/consts.ts @@ -90,7 +90,7 @@ export const SIGNER_KEY_MAP: Record { const hasBlockHeight = 'block_height' in tx; const blockBurnTime = hasBlockHeight ? tx.parent_burn_block_time_iso || tx.burn_block_time_iso : undefined; - const { data: historicalStxPrice } = useSuspenseStxPrice(blockBurnTime, { + const { data: historicalStxPrice } = useStxPrice(blockBurnTime, { enabled: !!blockBurnTime, }); - const { data: currentStxPrice } = useSuspenseStxPrice(); + const { data: currentStxPrice } = useStxPrice(); return { historicalStxPrice, currentStxPrice }; }; diff --git a/src/common/queries/useCurrentPrices.ts b/src/common/queries/useCurrentPrices.ts index 13d0571e2..af616ceba 100644 --- a/src/common/queries/useCurrentPrices.ts +++ b/src/common/queries/useCurrentPrices.ts @@ -1,6 +1,11 @@ 'use client'; -import { QueryFunctionContext, UseQueryOptions, useSuspenseQuery } from '@tanstack/react-query'; +import { + QueryFunctionContext, + UseQueryOptions, + useQuery, + useSuspenseQuery, +} from '@tanstack/react-query'; import { ONE_HOUR } from './query-stale-time'; @@ -11,12 +16,12 @@ const getHistoricalStxPrice = async ({ queryKey }: QueryFunctionContext) => { .then(data => data?.price || 0); }; -export const useSuspenseStxPrice = ( +export const useStxPrice = ( blockBurnTime?: string, options?: Partial> ) => { const blockBurnTimeDate = blockBurnTime?.split('T')[0]; - return useSuspenseQuery({ + return useQuery({ queryKey: ['stx-price', blockBurnTimeDate ? blockBurnTime.split('T')[0] : 'current'], queryFn: getHistoricalStxPrice, staleTime: blockBurnTime ? Infinity : ONE_HOUR * 3,