Skip to content

Commit

Permalink
fix: debounce amount calculation on wrap form
Browse files Browse the repository at this point in the history
  • Loading branch information
manneredboor committed Aug 29, 2023
1 parent 10a5aee commit cc9a855
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions features/wsteth/wrap/wrap-form-context/wrap-form-context.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import invariant from 'tiny-invariant';
import { useMemo, createContext, useContext } from 'react';
import { useForm, FormProvider } from 'react-hook-form';
import { useWstethBySteth } from 'shared/hooks';
import { useDebouncedValue, useWstethBySteth } from 'shared/hooks';
import { useWrapTxApprove } from '../hooks/use-wrap-tx-approve';
import { useWrapFormNetworkData } from '../hooks/use-wrap-form-network-data';
import { useWrapFormProcessor } from '../hooks/use-wrap-form-processing';
Expand Down Expand Up @@ -66,7 +66,9 @@ export const WrapFormProvider: React.FC = ({ children }) => {

const isSteth = token === TOKENS_TO_WRAP.STETH;

const willReceiveWsteth = useWstethBySteth(amount ?? Zero);
const amountDebounced = useDebouncedValue(amount, 500);

const willReceiveWsteth = useWstethBySteth(amountDebounced ?? Zero);

const value = useMemo(
(): WrapFormDataContextValueType => ({
Expand Down

0 comments on commit cc9a855

Please sign in to comment.