Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Fix Hydraation Error #10

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/(browse)/_components/sidebar/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { Hint } from "@/components/hint";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { useSidebar } from "@/store/use-sidebar";
import { ArrowLeftFromLine, ArrowRightFromLine } from "lucide-react";

Expand Down Expand Up @@ -38,3 +39,12 @@ export const Toggle = () => {
</>
);
};

export const ToggleSkeleton = () => {
return (
<div className="p-3 pl-6 mb-2 hidden lg:flex items-center justify-between w-full">
<Skeleton className="h-6 w-[100px]" />
<Skeleton className="h-6 w-6" />
</div>
);
};
13 changes: 13 additions & 0 deletions app/(browse)/_components/sidebar/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@
import { cn } from "@/lib/utils";
import { useSidebar } from "@/store/use-sidebar";
import React from "react";
import { useIsClient } from "usehooks-ts";
import { RecommendedSkeleton } from "./recommended";
import { ToggleSkeleton } from "./toggle";

interface WrapperProps {
children: React.ReactNode;
}

export const Wrapper = ({ children }: WrapperProps) => {
const isClient = useIsClient();
const { collapsed } = useSidebar((state) => state);

if (!isClient) {
return (
<aside className="fixed left-0 flex flex-col w-[70px] lg:w-60 h-full bg-background border-r border-[#2D2E35] z-50">
<ToggleSkeleton />
<RecommendedSkeleton />
</aside>
);
}

return (
<aside
className={cn(
Expand Down