Hello there, i use RadixUI, a react component UI lib. And I want to insert their <NavigationMenu.Link>
inside <PrismicNextLink>
. I kept have this error when I pass the field:LinkField
props :
Type 'AnyRegularField' is not assignable to type 'LinkField'.
Type 'null' is not assignable to type 'LinkField'.ts(2322)
MenuLink.tsx(6, 5): The expected type comes from property 'field' which is declared here on type 'IntrinsicAttributes & Props'
And this is my code :
page.tsx
export default function Homepage(){
const clientPrimic = createClient();
const settings = await clientPrimic.getSingle('settings');
const navigations = settings.data.navigation; // The FieldGroup contains label and link
return <Navbar navigations={navigations}/>
}
MenuLink.tsx
(where i insert the UI lib link into <PrismicNextLink>
)
import * as NavigationMenu from '@radix-ui/react-navigation-menu';
import { PrismicNextLink } from '@prismicio/next';
import { KeyTextField, LinkField } from '@prismicio/client';
interface Props {
field:LinkField;
children:KeyTextField;
}
export default function MenuLink({field, children}:Props) {
return (
<PrismicNextLink field={field} passHref legacyBehavior>
<NavigationMenu.Link>{children}</NavigationMenu.Link>
</PrismicNextLink>
)
}
Navbar.tsx
import * as NavigationMenu from '@radix-ui/react-navigation-menu';
import MenuLink from './components/MenuLink';
import { GroupField } from '@prismicio/client';
interface Props {
navigations:GroupField;
}
export default function Navbar({navigations}:Props) {
return (
<NavigationMenu.Root>
<NavigationMenu.List>
{navigations.map((item)=>{
return (
<NavigationMenu.Item>
<MenuLink field={item.link}> // Here comes the error i talked at beginning
{item.label} /* Here,nearly the same error, but saying "Type 'AnyRegularField' is not assignable to type 'KeyTextField'."*/
</MenuLink>
</NavigationMenu.Item>
)
})}
<NavigationMenu.Indicator />
</NavigationMenu.List>
<NavigationMenu.Viewport />
</NavigationMenu.Root>
)
}
Thanks for your help !