summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-03-30 14:36:24 -0300
committerSebastian <sebasjm@gmail.com>2022-03-30 14:36:24 -0300
commit89435696f9a28316ab3dc5ef7c73776d092da89c (patch)
tree6ead695277e252796dbf29dc1c5ee0023be90e99 /packages/taler-wallet-webextension/src/cta
parent8642f8edcd1aa8fe18c50d534f485debf1df01c9 (diff)
downloadwallet-core-89435696f9a28316ab3dc5ef7c73776d092da89c.tar.gz
wallet-core-89435696f9a28316ab3dc5ef7c73776d092da89c.tar.bz2
wallet-core-89435696f9a28316ab3dc5ef7c73776d092da89c.zip
useAsync use an optional deps for callback, most of the time it just need to be rendered once
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw.tsx40
1 files changed, 16 insertions, 24 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
index 64a0c2586..676c65d2d 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
@@ -247,9 +247,7 @@ export function WithdrawPageWithParsedURI({
const [reviewing, setReviewing] = useState<boolean>(false);
const [reviewed, setReviewed] = useState<boolean>(false);
- const knownExchangesHook = useAsyncAsHook(
- useCallback(() => wxApi.listExchanges(), []),
- );
+ const knownExchangesHook = useAsyncAsHook(wxApi.listExchanges);
const knownExchanges = useMemo(
() =>
@@ -278,21 +276,19 @@ export function WithdrawPageWithParsedURI({
[customExchange, thisCurrencyExchanges, uriInfo.defaultExchangeBaseUrl],
);
- const detailsHook = useAsyncAsHook(
- useCallback(async () => {
- if (!exchange) throw Error("no default exchange");
- const tos = await wxApi.getExchangeTos(exchange, ["text/xml"]);
+ const detailsHook = useAsyncAsHook(async () => {
+ if (!exchange) throw Error("no default exchange");
+ const tos = await wxApi.getExchangeTos(exchange, ["text/xml"]);
- const tosState = buildTermsOfServiceState(tos);
+ const tosState = buildTermsOfServiceState(tos);
- const info = await wxApi.getExchangeWithdrawalInfo({
- exchangeBaseUrl: exchange,
- amount: withdrawAmount,
- tosAcceptedFormat: ["text/xml"],
- });
- return { tos: tosState, info };
- }, [exchange, withdrawAmount]),
- );
+ const info = await wxApi.getExchangeWithdrawalInfo({
+ exchangeBaseUrl: exchange,
+ amount: withdrawAmount,
+ tosAcceptedFormat: ["text/xml"],
+ });
+ return { tos: tosState, info };
+ });
if (!detailsHook) {
return <Loading />;
@@ -357,14 +353,10 @@ export function WithdrawPageWithParsedURI({
}
export function WithdrawPage({ talerWithdrawUri }: Props): VNode {
const { i18n } = useTranslationContext();
- const uriInfoHook = useAsyncAsHook(
- useCallback(
- () =>
- !talerWithdrawUri
- ? Promise.reject(undefined)
- : wxApi.getWithdrawalDetailsForUri({ talerWithdrawUri }),
- [talerWithdrawUri],
- ),
+ const uriInfoHook = useAsyncAsHook(() =>
+ !talerWithdrawUri
+ ? Promise.reject(undefined)
+ : wxApi.getWithdrawalDetailsForUri({ talerWithdrawUri }),
);
if (!talerWithdrawUri) {