|
1 | 1 | import * as React from 'react'
|
2 |
| -import { createFileRoute, Link, useNavigate } from '@tanstack/react-router' |
| 2 | +import { createFileRoute, Link } from '@tanstack/react-router' |
3 | 3 | import { z } from 'zod'
|
4 | 4 | import {
|
5 | 5 | MdClose,
|
6 |
| - MdStarBorder, |
7 |
| - MdStar, |
8 | 6 | MdLock,
|
9 | 7 | MdLockOpen,
|
10 | 8 | MdVisibility,
|
11 | 9 | MdVisibilityOff,
|
12 | 10 | } from 'react-icons/md'
|
13 |
| -import { |
14 |
| - keepPreviousData, |
15 |
| - queryOptions, |
16 |
| - useQueries, |
17 |
| - useQuery, |
18 |
| - useSuspenseQuery, |
19 |
| -} from '@tanstack/react-query' |
| 11 | +import { keepPreviousData, queryOptions, useQuery } from '@tanstack/react-query' |
20 | 12 | import * as Plot from '@observablehq/plot'
|
21 | 13 | import { ParentSize } from '@visx/responsive'
|
22 | 14 | import { Tooltip } from '~/components/Tooltip'
|
@@ -425,14 +417,14 @@ export const Route = createFileRoute('/stats/npm/')({
|
425 | 417 | packageNames: search.packageNames,
|
426 | 418 | interval: search.interval,
|
427 | 419 | }),
|
428 |
| - loader: async ({ context, deps }) => { |
429 |
| - await context.queryClient.ensureQueryData( |
430 |
| - npmQueryOptions({ |
431 |
| - packageNames: deps.packageNames, |
432 |
| - interval: deps.interval, |
433 |
| - }) |
434 |
| - ) |
435 |
| - }, |
| 420 | + // loader: async ({ context, deps }) => { |
| 421 | + // await context.queryClient.ensureQueryData( |
| 422 | + // npmQueryOptions({ |
| 423 | + // packageNames: deps.packageNames, |
| 424 | + // interval: deps.interval, |
| 425 | + // }) |
| 426 | + // ) |
| 427 | + // }, |
436 | 428 | component: RouteComponent,
|
437 | 429 | })
|
438 | 430 |
|
@@ -479,7 +471,7 @@ function RouteComponent() {
|
479 | 471 | })
|
480 | 472 | }
|
481 | 473 |
|
482 |
| - const npmQuery = useSuspenseQuery( |
| 474 | + const npmQuery = useQuery( |
483 | 475 | npmQueryOptions({
|
484 | 476 | packageNames: packageNames || [],
|
485 | 477 | interval,
|
@@ -576,7 +568,7 @@ function RouteComponent() {
|
576 | 568 | })
|
577 | 569 | }
|
578 | 570 |
|
579 |
| - const validStats = npmQuery.data?.filter((data): data is NpmStats => { |
| 571 | + const validStats = (npmQuery.data ?? [])?.filter((data): data is NpmStats => { |
580 | 572 | if (!data) return false
|
581 | 573 | return Array.isArray(data.downloads) && data.downloads.length > 0
|
582 | 574 | })
|
@@ -752,7 +744,7 @@ function RouteComponent() {
|
752 | 744 | </thead>
|
753 | 745 | <tbody className="bg-white dark:bg-gray-900">
|
754 | 746 | {npmQuery.data
|
755 |
| - .map((stats) => { |
| 747 | + ?.map((stats) => { |
756 | 748 | if (!stats?.downloads?.length) return null
|
757 | 749 |
|
758 | 750 | // Sort downloads by date
|
|
0 commit comments