From c738de21583c2bae810cda66b53e6a5e8f88953c Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Wed, 13 Sep 2023 16:52:31 +0200 Subject: [PATCH 1/2] Fix buy value recalc race condition --- .../CreateOrder/EditSellAmount/EditSellAmount.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx index b719ccfa80..e007436ebd 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx @@ -68,7 +68,7 @@ export const EditSellAmount = () => { } React.useEffect(() => { - recalculateBuyValue(quantity) + setTimeout(() => recalculateBuyValue(quantity), 100) // eslint-disable-next-line react-hooks/exhaustive-deps }, [buyTokenInfo?.id]) From ee8cbea8a5027e7f279f22e47bb7f83f52fc6309 Mon Sep 17 00:00:00 2001 From: jorbuedo Date: Thu, 14 Sep 2023 10:18:32 +0200 Subject: [PATCH 2/2] Remove setTimeout --- .../CreateOrder/EditSellAmount/EditSellAmount.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx index e007436ebd..c1f3c7828d 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/CreateOrder/EditSellAmount/EditSellAmount.tsx @@ -68,9 +68,9 @@ export const EditSellAmount = () => { } React.useEffect(() => { - setTimeout(() => recalculateBuyValue(quantity), 100) + recalculateBuyValue(quantity) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [buyTokenInfo?.id]) + }, [buyTokenInfo?.id, createOrder?.selectedPool?.poolId]) const onChangeQuantity = (text: string) => { try {