Commit a73f59b4 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: only debounce input amounts (#3540)

parent 7a75626c
...@@ -42,10 +42,10 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr ...@@ -42,10 +42,10 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr
trade: InterfaceTrade<Currency, Currency, TTradeType> | undefined trade: InterfaceTrade<Currency, Currency, TTradeType> | undefined
} { } {
// Debounce is used to prevent excessive requests to SOR, as it is data intensive. // Debounce is used to prevent excessive requests to SOR, as it is data intensive.
// This helps provide a "syncing" state the UI can reference for loading animations. // Fast user actions (ie updating the input) should be debounced, but currency changes should not.
const inputs = useMemo(() => [tradeType, amountSpecified, otherCurrency], [tradeType, amountSpecified, otherCurrency]) const debouncedAmountSpecified = useDebounce(amountSpecified, 200)
const debouncedInputs = useDebounce(inputs, 200) const isDebouncing =
const isDebouncing = inputs !== debouncedInputs amountSpecified !== debouncedAmountSpecified && amountSpecified?.currency === debouncedAmountSpecified?.currency
const chainId = amountSpecified?.currency.chainId const chainId = amountSpecified?.currency.chainId
const { library } = useActiveWeb3React() const { library } = useActiveWeb3React()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment