Skip to content
Discussion options

You must be logged in to vote

Nvm it was pretty easy implementation.

"use client";

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import React, { useState } from "react";
import { Skeleton } from "../ui/skeleton";
import { cn } from "@/lib/utils";

export const NavAvatar: React.FC<{ src: string; username: string }> = ({
  src,
  username,
}) => {
  const [isLoaded, setIsLoaded] = useState(false);

  return (
    <React.Fragment>
      <Avatar className={cn(isLoaded ? "" : "hidden")}>
        <AvatarImage
          src={src}
          onLoadingStatusChange={(status) => {
            status === "loaded" ? setIsLoaded(true) : null;
          }}
        />
      </Avatar>
      {!isLoaded ? (

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@arifwp
Comment options

Answer selected by ksamirdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants