Skip to content

Commit

Permalink
fix: useId instead of random number for tooltip ID
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcgrath13 committed Feb 24, 2025
1 parent e4542dc commit 389dfb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export function Tooltip<
}: DefaultTooltipProps | CustomTooltipProps<FCProps>): ReactElement {
const triggerElementRef = useRef<HTMLElement & HTMLButtonElement>(null)
const tooltipBodyRef = useRef<HTMLElement>(null)
const tooltipID = useRef(
`tooltip-${Math.floor(Math.random() * 900000) + 100000}`
)
const tooltipID = `tooltip-${useId()}`

const [isVisible, setVisible] = useState(false)
const [isShown, setIsShown] = useState(false)
Expand Down Expand Up @@ -291,3 +289,6 @@ export function Tooltip<
)
}
}
function useId() {
throw new Error('Function not implemented.')
}

0 comments on commit 389dfb5

Please sign in to comment.