Skip to content

Commit

Permalink
fix: Fix ref issues with Link component
Browse files Browse the repository at this point in the history
  • Loading branch information
baumandm committed Feb 24, 2022
1 parent 4fb27b7 commit 8f421d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/frontend/src/components/link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
*/

import { Link as ChakraLink, LinkProps as ChakraLinkProps } from '@chakra-ui/react';
import React, { forwardRef } from 'react';
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom';

/**
* Custom link component that composes Chakra-UI presentation with React Router functionality
*
* @param props RouterLinkProps
*/
export const Link = ({ underline = true, ...props }: { underline?: boolean } & RouterLinkProps & ChakraLinkProps) => (
<ChakraLink as={RouterLink} {...(!underline ? { _hover: { textDecoration: 'none' } } : {})} {...props} />
export const Link = forwardRef(
(
{ underline = true, ...props }: { underline?: boolean } & RouterLinkProps & ChakraLinkProps,
ref: React.Ref<any>
) => (
<ChakraLink ref={ref} as={RouterLink} {...(!underline ? { _hover: { textDecoration: 'none' } } : {})} {...props} />
)
);

0 comments on commit 8f421d0

Please sign in to comment.