I am using Next.js's Link component and am trying to pass a Link Href down a component, but am receiving
Uncaught TypeError: Parameter 'url' must be a string, not function.
This makes sense, although I would like the href to be a string not a function, Below is my code.
//ParentComponent.js
//The function is passed down to ChildComponent.js
handleClick = url => () => {
if (!url) {
return '/link';
}
return '/link2/;
};
//ChildComponent.js
//Link is a Next.js link (next/link)
//Array is also functional
{
array.map((link, i) => ( <
Link href = {
handleClick(link.url || null)
} >
<
/Link>
))
}
Thanks!