From cebe3c033673db338ae5ec84ffef4fe8ad4c3dbe Mon Sep 17 00:00:00 2001 From: bonomat Date: Mon, 22 Nov 2021 17:54:45 +1100 Subject: [PATCH] Use form and form submit for better handling --- taker-frontend/src/components/Wallet.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taker-frontend/src/components/Wallet.tsx b/taker-frontend/src/components/Wallet.tsx index 6e9367f..26f9b93 100644 --- a/taker-frontend/src/components/Wallet.tsx +++ b/taker-frontend/src/components/Wallet.tsx @@ -24,7 +24,7 @@ import { VStack, } from "@chakra-ui/react"; import * as React from "react"; -import { useState } from "react"; +import { FormEvent, useState } from "react"; import { useAsync } from "react-async"; import { useNavigate } from "react-router-dom"; import { postWithdraw } from "../App"; @@ -50,7 +50,8 @@ export default function Wallet( const [withdrawAddress, setWithdrawAddress] = useState(""); let { run: runWithdraw, isLoading: isWithdrawing } = useAsync({ - deferFn: async () => { + deferFn: async ([event]: FormEvent[]) => { + event.preventDefault(); try { const url = await postWithdraw({ amount: withdrawAmount, @@ -68,7 +69,6 @@ export default function Wallet( isClosable: true, }); } catch (e) { - console.log(`Caught an error: ${e}`); createErrorToast(toast, e); } },