Skip to content

Commit 5fc8110

Browse files
fix: showing NaN for Npm Downloads in the tanstack/config page (#516)
* fix: showing NaN for Npm Downloads in the tanstack/config page Handle non-finite values for npm download count. * style: run prettier --------- Co-authored-by: SeanCassiere <[email protected]>
1 parent 594754a commit 5fc8110

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/OpenSourceStats.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const NpmDownloadCounter = ({
5858
npmData: Parameters<typeof useNpmDownloadCounter>[0]
5959
}) => {
6060
const { count, intervalMs } = useNpmDownloadCounter(npmData)
61+
if (!Number.isFinite(count)) {
62+
// this returns true for NaN, Infinty / -Infinty, null, undefined
63+
return '-'
64+
}
6165
return <StableCounter value={count} intervalMs={intervalMs} />
6266
}
6367

0 commit comments

Comments
 (0)