From 14592496d9671fbb24e1aecaebc00b8e9bbdc071 Mon Sep 17 00:00:00 2001 From: Corban Riley Date: Wed, 8 Jan 2025 13:09:08 -0500 Subject: [PATCH] GradientAvatar svg ids are now unique --- .../GradientAvatar/GradientAvatar.tsx | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/GradientAvatar/GradientAvatar.tsx b/src/components/GradientAvatar/GradientAvatar.tsx index 6dc32bb8e..9ede1d5fb 100644 --- a/src/components/GradientAvatar/GradientAvatar.tsx +++ b/src/components/GradientAvatar/GradientAvatar.tsx @@ -1,5 +1,5 @@ import { clsx } from 'clsx' -import { Fragment, memo } from 'react' +import { Fragment, memo, useId } from 'react' import { Box, BoxProps } from '~/components/Box' @@ -9,6 +9,8 @@ const MOD = 1000 const SIZE = 64 const RADIUS = SIZE / 2 +const prefix = 'gradient-avatar-' + type GradientAvatarProps = { address: string initials?: string @@ -93,10 +95,13 @@ const createGradients = (address: string, complexity: number) => { } }) } + export const GradientAvatar = memo((props: GradientAvatarProps) => { const { className, address, size = 'md', complexity = 1, ...rest } = props const gradients = createGradients(address, complexity) + const id = useId() + return ( { {...rest} > - + { { {gradients.map((gradient, idx) => ( - + - + @@ -162,24 +167,24 @@ export const GradientAvatar = memo((props: GradientAvatarProps) => { ))} - + - + {gradients.map((gradient, idx) => (