CustomAvatar not recognized
i get the following error in the customavatar file inside components folder: Cannot redeclare block-scoped variable 'CustomAvatar'.ts(2451)
const CustomAvatar: ({ name, style, ...rest }: Props) => JSX.Element. this is my code:
import React from "react";
import type { AvatarProps } from "antd";
import { Avatar as AntdAvatar } from "antd";
import { getNameInitials, getRandomColorFromString } from "@/utilities";
type Props = AvatarProps & {
name?: string;
};
const CustomAvatar = ({ name = "", style, ...rest }: Props) => {
return (
<AntdAvatar
alt={name}
size="small"
style={{
backgroundColor: rest?.src
? "transparent"
: getRandomColorFromString(name),
display: "flex",
alignItems: "center",
border: "none",
...style,
}}
{...rest}
>
{getNameInitials(name)}
</AntdAvatar>
);
};
export const CustomAvatar = React.memo(
CustomAvatar,
(prevProps, nextProps) => {
return prevProps.name === nextProps.name && prevProps.src === nextProps.src;
},
);
const CustomAvatar: ({ name, style, ...rest }: Props) => JSX.Element. this is my code:
import React from "react";
import type { AvatarProps } from "antd";
import { Avatar as AntdAvatar } from "antd";
import { getNameInitials, getRandomColorFromString } from "@/utilities";
type Props = AvatarProps & {
name?: string;
};
const CustomAvatar = ({ name = "", style, ...rest }: Props) => {
return (
<AntdAvatar
alt={name}
size="small"
style={{
backgroundColor: rest?.src
? "transparent"
: getRandomColorFromString(name),
display: "flex",
alignItems: "center",
border: "none",
...style,
}}
{...rest}
>
{getNameInitials(name)}
</AntdAvatar>
);
};
export const CustomAvatar = React.memo(
CustomAvatar,
(prevProps, nextProps) => {
return prevProps.name === nextProps.name && prevProps.src === nextProps.src;
},
);
