Skip to content

Commit

Permalink
perf: remove unnecesarry for loop in project skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
moonbamijam committed May 10, 2024
1 parent 4ef2e47 commit 144014d
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions components/skeletons/ProjectSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import { useFetch } from "@hooks/useFetch";
import Grid from "@components/common/Grid";
import Section from "@components/common/Section";
import SkeletonScreen from "@components/ui/SkeletonScreen";
import { useFetch } from "@hooks/useFetch";

export default async function ProjectSkeleton() {
const { projects } = await useFetch("/api/projects");

// let's find how many projects we have and store it in skeletonsScreenCount
let skeletonScreenCount = 0;
for (let i = 0; i < projects.length; i++) {
skeletonScreenCount++;
}

// compare the i to the skeletonScreenCount and push its count to projectSkeletons array
const projectSkeletons: any = [];
for (let i = 0; i < skeletonScreenCount; i++) {
projectSkeletons.push(i);
}

const renderProjectSkeletons = () => {
return projectSkeletons.map((projectSkeleton: any) => (
return projects.map((projectSkeleton: any) => (
<SkeletonScreen
key={projectSkeleton}
width="w-[400px] "
Expand All @@ -31,11 +19,11 @@ export default async function ProjectSkeleton() {

return (
<Section id={"project"} contentStyles={"gap-[64px]"}>
<div className="title flex flex-col items-center gap-y-4">
<div className="title flex flex-col items-center gap-y-2">
<SkeletonScreen
id="heading"
width="w-[250px]"
height="h-[48px]"
height="h-[60px]"
customStyles="rounded-lg"
/>
<SkeletonScreen
Expand Down

0 comments on commit 144014d

Please sign in to comment.