<Link> getting undefined when trying to use it with props #21610
Replies: 4 comments 5 replies
-
When I try on a simple example, passing a prop to Link's href works. Maybe your goBackTo prop is really undefined ? Could you console.log it to see if it displays the value ? |
Beta Was this translation helpful? Give feedback.
-
@mkrtchian I am getting this error ::
My code is this import React from "react";
import Link from "next/link";
export default ({ title, address }) => {
return (
<Link
href="/"
className="h-full
w-max
pb-2
px-2
border-b-4
border-transparent
text-white
hover:border-white dark:hover:border-myPrimaryDark
dark:hover:border-myLightTone
transition-all duration-200 "
>
{title}
</Link>
);
}; import React from "react";
import Link from "next/link";
export default ({ title, address }) => {
return (
<Link
href="/"
className="h-full
flex items-center border-b-4
border-transparent
hover:text-white
hover:border-white dark:hover:border-myPrimaryDark
dark:hover:border-myLightTone
transition-all duration-200 "
>
{title}
</Link>
);
}; I dont't Know why i am getting the errror. |
Beta Was this translation helpful? Give feedback.
-
@danilo-leal just write it this way <Link href={`/${props.goBackTo}`}>
<a>
<svg
className="w-4 h-4 fill-current text-draplin"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="3"
d="M10 19l-7-7m0 0l7-7m-7 7h18">
</path>
</svg>
</a>
</Link> |
Beta Was this translation helpful? Give feedback.
-
I am facing the same error. what's wrong with my code ?
|
Beta Was this translation helpful? Give feedback.
-
Hey, y'all!
I'm trying to use the
<Link>
feature in some of my components but I'm getting the following error: Failed prop type: The prophref
expects astring
orobject
in<Link>
, but gotundefined
instead.Here's a code snippet of mine as to how I'm trying to use passing a prop:
I've been meaning to replace all the
<a>
tags I'm using throughout all of my site to the next Link but I have no clue as to how to proceed here. I'd appreciate it if anyone shed a light here!Beta Was this translation helpful? Give feedback.
All reactions