Skip to content

Commit

Permalink
fix: catch when ref is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul Ranete committed Jan 30, 2025
1 parent 05c820c commit c2d834e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/wallet/frontend/src/ui/ButtonOrLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ export const ButtonOrLink = forwardRef<
ButtonOrLinkProps
>(({ href, ...props }, ref) => {
const isLink = typeof href !== 'undefined'

if (isLink && isHTMLAnchorElement(ref, isLink)) {
return <Link href={href} ref={ref} {...props} />
}

if (isHTMLButtonElement(ref, isLink)) {
return <button {...props} type={props.type ?? 'button'} ref={ref} />
}

if (!ref && isLink) {
return <Link href={href} {...props} />
}
})

ButtonOrLink.displayName = 'ButtonOrLink'
Expand Down

0 comments on commit c2d834e

Please sign in to comment.