Skip to content

Commit 4ae27bb

Browse files
chore(web): improve npm version logic
1 parent b06fa74 commit 4ae27bb

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

apps/web/src/app/(home)/_components/npm-package.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
"use client";
22

33
import { useEffect, useState } from "react";
4-
import { cn } from "@/lib/utils";
54

65
const NpmPackage = () => {
7-
const [version, setVersion] = useState("");
8-
const [versionLoading, setVersionLoading] = useState(true);
6+
const [version, setVersion] = useState("0.0.0");
97

108
useEffect(() => {
119
const getLatestVersion = async () => {
12-
setVersionLoading(true);
1310
try {
1411
const res = await fetch(
1512
"https://api.github.com/repos/AmanVarshney01/create-better-t-stack/releases",
@@ -21,24 +18,15 @@ const NpmPackage = () => {
2118
} catch (error) {
2219
console.error("Error fetching NPM version:", error);
2320
setVersion("?.?.?");
24-
} finally {
25-
setVersionLoading(false);
2621
}
2722
};
2823
getLatestVersion();
2924
}, []);
3025

3126
return (
3227
<div className="mt-2 flex items-center justify-center">
33-
<span
34-
className={cn(
35-
"mr-2 inline-block h-5 w-3 bg-primary",
36-
versionLoading && "animate-pulse",
37-
)}
38-
/>
39-
<span className=" text-muted-foreground text-xl">
40-
{versionLoading ? "[v?.?.?]" : `[v${version}]`}
41-
</span>
28+
<span className="mr-2 inline-block h-5 w-3 bg-primary" />
29+
<span className="text-muted-foreground text-xl">[v{version}]</span>
4230
</div>
4331
);
4432
};

0 commit comments

Comments
 (0)