Last active
February 19, 2024 05:29
-
-
Save ShellWen/ec7a97a1e74799bcab18463960e2db6f to your computer and use it in GitHub Desktop.
A Link wrapper for Chakra-UI and React Router v6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { ComponentWithAs, Link as ChakraLink, LinkProps as RawChakraLinkProps } from '@chakra-ui/react' | |
import { Link as ReactRouterLink } from 'react-router-dom' | |
type Props = Omit<React.ComponentPropsWithoutRef<ComponentWithAs<typeof ReactRouterLink, RawChakraLinkProps>>, 'as'> | |
const Link: React.FC<Props> = ({ children, ...props }) => ( | |
// eslint-disable-next-line react/jsx-props-no-spreading | |
<ChakraLink as={ReactRouterLink} {...props}> | |
{children} | |
</ChakraLink> | |
) | |
export default Link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment