Skip to content

Commit

Permalink
No flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Anttonen committed Sep 2, 2021
1 parent 73c339a commit 0ea4500
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions hooks/useUserPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function useUserPositions(
const filterUserTokens = async (
tokens: Token[],
): Promise<Token[] | null> => {
let tokensWithBalance: Token[] | null = null
let tokensWithBalance = []
if (vanillaRouter && isAddress(userAddress) && isAddress(vnl.address)) {
try {
tokensWithBalance = await getUserPositions(
Expand All @@ -45,7 +45,6 @@ function useUserPositions(
)
} catch (e) {
console.error(e)
tokensWithBalance = []
}
}

Expand Down
11 changes: 6 additions & 5 deletions pages/trade/[userAddress].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const HeaderContent = ({ initialTokens }: HeaderContentProps): JSX.Element => {
const getUserTokens = useCallback(() => {
const v2Tokens = userV2Tokens || []
const v3Tokens =
userV3Tokens.length > 0 ? userV3Tokens : initialTokens || []
userV3Tokens?.length > 0 ? userV3Tokens : initialTokens || []
return [...v2Tokens, ...v3Tokens]
}, [initialTokens, userV2Tokens, userV3Tokens])

Expand Down Expand Up @@ -141,7 +141,7 @@ const HeaderContent = ({ initialTokens }: HeaderContentProps): JSX.Element => {
</div>
</Column>
)}
{getUserTokens() && getUserTokens().length === 0 ? (
{getUserTokens()?.length === 0 ? (
<Column width={Width.EIGHT}>
<Title>Start Trading</Title>
<HugeMonospace>
Expand Down Expand Up @@ -355,9 +355,10 @@ const BodyContent = ({
return (
userPositionsV3?.filter((token) => token.profit && token.profit > 0)
.length ||
initialTokens.userPositionsV3?.filter(
initialTokens?.userPositionsV3?.filter(
(token) => token.profit && token.profit > 0,
).length
).length ||
0
)
}, [initialTokens.userPositionsV3, userPositionsV3])

Expand Down Expand Up @@ -436,7 +437,7 @@ const BodyContent = ({
MY POSITIONS
<small>{`${profitablePositions()} of ${
userPositionsV3
? userPositionsV3.length
? userPositionsV3?.length
: initialTokens.userPositionsV3.length
} profitable`}</small>
</h2>
Expand Down

0 comments on commit 0ea4500

Please sign in to comment.