Prevent flash of "No markets found" on search load
This commit is contained in:
parent
688ebb797a
commit
c5660ab762
|
@ -191,13 +191,16 @@ export function ContractSearchInner(props: {
|
||||||
filter === 'resolved' ? true : filter === 'all' ? undefined : false
|
filter === 'resolved' ? true : filter === 'all' ? undefined : false
|
||||||
)
|
)
|
||||||
|
|
||||||
const { showMore, hits, isLastPage, results } = useInfiniteHits()
|
const [isInitialLoad, setIsInitialLoad] = useState(true)
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setTimeout(() => setIsInitialLoad(false), 1000)
|
||||||
|
return () => clearTimeout(id)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const { showMore, hits, isLastPage } = useInfiniteHits()
|
||||||
const contracts = hits as any as Contract[]
|
const contracts = hits as any as Contract[]
|
||||||
|
|
||||||
const router = useRouter()
|
if (isInitialLoad && contracts.length === 0) return <></>
|
||||||
const hasLoaded = contracts.length > 0 || router.isReady
|
|
||||||
|
|
||||||
if (!hasLoaded || !results) return <></>
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContractsGrid
|
<ContractsGrid
|
||||||
|
|
Loading…
Reference in New Issue
Block a user