Skip to content
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

Fix all user NFTs showing before mutate method is called #574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/UserTokensGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useEffect } from 'react'
import { FC, useEffect, useState } from 'react'
import LoadingCard from './LoadingCard'
import { useUserTokens } from '@reservoir0x/reservoir-kit-ui'
import { useInView } from 'react-intersection-observer'
Expand All @@ -17,6 +17,7 @@ type Props = {
}

const UserTokensGrid: FC<Props> = ({ fallback, owner }) => {
const [mutated, setMutated] = useState<boolean>(false)
const userTokensParams: Parameters<typeof useUserTokens>['1'] = {
limit: 20,
includeTopBid: true,
Expand All @@ -36,7 +37,7 @@ const UserTokensGrid: FC<Props> = ({ fallback, owner }) => {
})

useEffect(() => {
userTokens.mutate()
userTokens.mutate().then(() => setMutated(true))
return () => {
userTokens.setSize(1)
}
Expand Down Expand Up @@ -65,6 +66,10 @@ const UserTokensGrid: FC<Props> = ({ fallback, owner }) => {
)
}

if (!mutated) {
return <div></div>
}

return (
<div className="mx-auto mb-8 grid max-w-[2400px] gap-8 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-4 2xl:grid-cols-5">
{isFetchingInitialData
Expand Down