Next.js Discord

Discord Forum

MobileLink error in mobile-nav.tsx

Answered
QBit posted this in #help-forum
Open in Discord
Avatar
How to resolve this error?
Image
Answered by QBit
in MobileLinkProps added children?: React.ReactNode and it fixed
View full answer

4 Replies

Avatar
interface MobileLinkProps extends LinkProps {
  onOpenChange?: (open: boolean) => void
  children: React.ReactNode
  className?: string
}
function MobileLink({
  href,
  onOpenChange,
  className,
  children,
  ...props
}: MobileLinkProps) {
  const router = useRouter()
  return (
    <Link
      href={href}
      onClick={() => {
        router.push(href.toString())
        onOpenChange?.(false)
      }}
      className={cn(className)}
      {...props}
    >
      {children}
    </Link>
  )
}
Image
Avatar
in MobileLinkProps added children?: React.ReactNode and it fixed
Answer