tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
571 stars 23 forks source link

Error when using custom Link component #103

Closed branikclimbs closed 1 year ago

branikclimbs commented 1 year ago

I am getting this error when I use my custom Link component Type 'string' is not assignable to type 'Route | Query' but It works with default Link component from next js. I am doing something wrong?

this is my custom Link component

import NextLink, { LinkProps as NextLinkProps } from 'next/link'

export type LinkProps = Omit<NextLinkProps, 'passHref' | 'as'> & Omit<ChakraLinkProps, 'href'>

export const Link: React.FC<React.PropsWithChildren<LinkProps>> = ({
  children,
  href,
  onClick,
  className,
  replace,
  scroll,
  shallow,
  prefetch,
  locale,
  ...props
}) => {
  return (
    <NextLink href={href} legacyBehavior passHref>
      <ChakraLink {...props}>{children}</ChakraLink>
    </NextLink>
  )
}

When I use it like this I will get error I mentioned above but when I import Link from next js everything works as expected.

<Link href="/users">text</Link>
tatethurston commented 1 year ago

Thanks for reporting this @branislaav. This is fixed in 1.0.4