From a9550e1331aa6ff7b29d4c651cfd905ba71bf215 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 29 Oct 2020 12:42:19 +0100 Subject: [PATCH] add a debounce to remove liquidity slider --- src/components/organisms/AssetActions/Pool/Remove.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/AssetActions/Pool/Remove.tsx b/src/components/organisms/AssetActions/Pool/Remove.tsx index a49eba880..eeab15b43 100644 --- a/src/components/organisms/AssetActions/Pool/Remove.tsx +++ b/src/components/organisms/AssetActions/Pool/Remove.tsx @@ -17,6 +17,7 @@ import Button from '../../../atoms/Button' import { getMaxValuesRemove } from './utils' import { graphql, useStaticQuery } from 'gatsby' import PriceUnit from '../../../atoms/Price/PriceUnit' +import debounce from 'lodash.debounce' const contentQuery = graphql` query PoolRemoveQuery { @@ -130,7 +131,7 @@ export default function Remove({ useEffect(() => { if (!ocean || !poolTokens) return - async function getValues() { + const getValues = debounce(async () => { const amountPoolShares = (Number(amountPercent) / 100) * Number(poolTokens) setAmountPoolShares(`${amountPoolShares}`) @@ -151,7 +152,7 @@ export default function Remove({ ) setAmountOcean(amountOcean) } - } + }, 300) getValues() }, [amountPercent, isAdvanced, ocean, poolTokens, poolAddress])