Skip to content

Commit 4abf7a7

Browse files
committed
Fix Conditionally rendered hook error in Buy with Fiat flow (#4211)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on fixing a conditionally rendered hook error when buying funds using fiat. ### Detailed summary - Added a new `onPostOnrampSuccess` function to handle successful post onramp swap - Changed the logic to report fiat status instead of post onramp swap status after successful swap > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 8b0fd13 commit 4abf7a7

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.changeset/thirty-bottles-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix Conditionally rendered hook error when Buying funds using fiat

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ export function FiatFlow(props: {
6868
props.openedWindow,
6969
);
7070

71+
const onPostOnrampSuccess = useCallback(() => {
72+
// report the status of fiat status instead of post onramp swap status when post onramp swap is successful
73+
getBuyWithFiatStatus({
74+
intentId: props.quote.intentId,
75+
client: props.client,
76+
}).then((status) => {
77+
props.onSuccess(status);
78+
});
79+
}, [props.onSuccess, props.quote.intentId, props.client]);
80+
7181
if (screen.id === "step-1") {
7282
return (
7383
<FiatSteps
@@ -110,16 +120,6 @@ export function FiatFlow(props: {
110120
);
111121
}
112122

113-
const onPostOnrampSuccess = useCallback(() => {
114-
// report the status of fiat status instead of post onramp swap status when post onramp swap is successful
115-
getBuyWithFiatStatus({
116-
intentId: props.quote.intentId,
117-
client: props.client,
118-
}).then((status) => {
119-
props.onSuccess(status);
120-
});
121-
}, [props.onSuccess, props.quote.intentId, props.client]);
122-
123123
if (screen.id === "postonramp-swap") {
124124
return (
125125
<PostOnRampSwapFlow

0 commit comments

Comments
 (0)