Skip to content

Commit

Permalink
fix: exchange rate hook is undefined on first render
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Apr 28, 2023
1 parent 7d1b136 commit 6fd0c06
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/widget/src/pages/SwapPage/SwapPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ExchangeRateUpdateParams } from '@lifi/sdk';
import DeleteIcon from '@mui/icons-material/Delete';
import { Box, Button, Tooltip } from '@mui/material';
import { useCallback, useRef, useState } from 'react';
Expand Down Expand Up @@ -34,10 +35,17 @@ export const SwapPage: React.FC = () => {
const tokenValueBottomSheetRef = useRef<BottomSheetBase>(null);
const exchangeRateBottomSheetRef = useRef<ExchangeRateBottomSheetBase>(null);

const onAcceptExchangeRateUpdate = (
resolver: (value: boolean) => void,
data: ExchangeRateUpdateParams,
) => {
exchangeRateBottomSheetRef.current?.open(resolver, data);
};

const { route, status, executeRoute, restartRoute, deleteRoute } =
useRouteExecution({
routeId: routeId,
onAcceptExchangeRateUpdate: exchangeRateBottomSheetRef.current?.open,
onAcceptExchangeRateUpdate,
});

const handleExecuteRoute = useCallback(() => {
Expand Down

0 comments on commit 6fd0c06

Please sign in to comment.