-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Deposit/Withdraw) Change bridge top bar on deposit address and remove awaiting BTC on more than 1 transfer #3987
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ import { | |
useMemo, | ||
useState, | ||
} from "react"; | ||
import { useMeasure } from "react-use"; | ||
import { useMeasure, useUnmount } from "react-use"; | ||
|
||
import { Icon } from "~/components/assets"; | ||
import { BridgeReceiveAssetDropdown } from "~/components/bridge/bridge-receive-asset-dropdown"; | ||
|
@@ -41,7 +41,7 @@ import { | |
useFeatureFlags, | ||
useTranslation, | ||
} from "~/hooks"; | ||
import { BridgeScreen } from "~/hooks/bridge"; | ||
import { BridgeScreen, useBridgeStore } from "~/hooks/bridge"; | ||
import { useEvmWalletAccount, useSwitchEvmChain } from "~/hooks/evm-wallet"; | ||
import { usePrice } from "~/hooks/queries/assets/use-price"; | ||
import { BridgeChainWithDisplayInfo } from "~/server/api/routers/bridge-transfer"; | ||
|
@@ -609,6 +609,10 @@ export const AmountScreen = observer( | |
toChain, | ||
]); | ||
|
||
useUnmount(() => { | ||
useBridgeStore.getState().setType("quote"); | ||
}); | ||
|
||
/** If an asset is disabled */ | ||
const areAssetTransfersDisabled = useMemo(() => { | ||
return direction === "withdraw" | ||
|
@@ -802,6 +806,7 @@ export const AmountScreen = observer( | |
toChain && | ||
toAsset | ||
) { | ||
useBridgeStore.getState().setType("deposit-address"); | ||
return ( | ||
<DepositAddressScreen | ||
canonicalAsset={canonicalAsset} | ||
|
@@ -851,6 +856,8 @@ export const AmountScreen = observer( | |
); | ||
} | ||
|
||
useBridgeStore.getState().setType("quote"); | ||
|
||
Comment on lines
+859
to
+860
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid mutating state during render Similar to the previous issue, calling Move this state mutation into a - useBridgeStore.getState().setType("quote");
/**
* This will trigger an error boundary
*/
if (!supportedSourceAssets && !isLoading) {
throw new Error("Supported source assets are not defined");
}
+ useEffect(() => {
+ useBridgeStore.getState().setType("quote");
+ }, []);
|
||
/** | ||
* This will trigger an error boundary | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid mutating state during render
Calling
useBridgeStore.getState().setType("deposit-address")
directly within the render path can cause side effects during rendering, which violates React's principle that render functions should be pure and side-effect free. This can lead to unexpected behavior and difficult-to-trace bugs.Consider moving this state mutation into a
useEffect
hook to ensure it runs after the component renders: