Skip to content

Commit

Permalink
placeholderData
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-schrammel committed Jun 29, 2024
1 parent a2508e6 commit 038d7b7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/__swaps__/screens/Swap/hooks/useSwapEstimatedGasLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function useSwapEstimatedGasLimit(
{ chainId, quote, assetToSell }: EstimateSwapGasLimitArgs,
config: QueryConfigWithSelect<EstimateSwapGasLimitResult, Error, EstimateSwapGasLimitResult, EstimateSwapGasLimitQueryKey> = {}
) {
const initialData = chainId && { chainId, gasLimit: gasUnits.basic_swap[chainId] };
const placeholderData = chainId && { chainId, gasLimit: gasUnits.basic_swap[chainId] };
const { data, isFetching } = useQuery(
estimateSwapGasLimitQueryKey({
chainId,
Expand All @@ -85,8 +85,7 @@ export function useSwapEstimatedGasLimit(
notifyOnChangeProps: ['data', 'isFetching'],
keepPreviousData: true,
enabled: !!chainId && !!quote && !!assetToSell && assetToSell.chainId === chainId,
initialData,
initialDataUpdatedAt: 0,
placeholderData,
...config,
}
);
Expand All @@ -95,7 +94,7 @@ export function useSwapEstimatedGasLimit(
// which is great when refetching for the same chainId, but we don't want to keep the previous data
// when fetching for a different chainId
return {
data: data && data.chainId === chainId ? data.gasLimit : initialData?.gasLimit,
data: data && data.chainId === chainId ? data.gasLimit : placeholderData?.gasLimit,
isFetching,
};
}

0 comments on commit 038d7b7

Please sign in to comment.