Skip to content

Commit

Permalink
940: Fixed RateField reverse rate bug (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
piersss committed Jul 19, 2024
1 parent 2a879f3 commit fdb8ece
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ export const RateField: React.FC<RateFieldProps> = ({
[currentRate]
);

const firstDisplayedToken = invertPair ? token2 : token1;
const secondDisplayedToken = invertPair ? token1 : token2;

useEffect(() => {
setCurrentRate(rate);
}, [rate]);
}, [rate.toString()]);

useEffect(() => {
setInvertPair(false);
}, [token1, token2, rate]);
}, [token1, token2, rate.toString()]);

function handleClick() {
const newInvertState = !invertPair;
Expand All @@ -56,10 +59,10 @@ export const RateField: React.FC<RateFieldProps> = ({
isButton={isButton}
className={className}
>
1<Text>{invertPair ? token2 : token1}</Text>
1<Text title={firstDisplayedToken}>{firstDisplayedToken}</Text>
<Equals>=</Equals>
<RateBox>{displayRate}</RateBox>
<Text>{invertPair ? token1 : token2}</Text>
<RateBox title={displayRate}>{displayRate}</RateBox>
<Text title={secondDisplayedToken}>{secondDisplayedToken}</Text>
{isButton ? (
<Icon name="swap-horizontal" iconSize={0.75} />
) : (
Expand Down

0 comments on commit fdb8ece

Please sign in to comment.