Type 'AnyRegularField' is not assignable to type 'LinkField'

I ve found a solution, from the poste here.
Basing the accepted answer, we have two solutions, I used the second one, that is asserting the type of the field like this :

return (
            <NavigationMenu.Item>
            <MenuLink field={item.link as LinkField}> // Here comes the error i talked at beginning
               {item.label as KeyTextField} /* Here,nearly the same error, but saying "Type 'AnyRegularField' is not assignable to type 'KeyTextField'."*/
            </MenuLink>
          </NavigationMenu.Item>
        )

When I refresh the page, there's a error like this :
TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function

This is because the Radix UI component should be put into a client-side component. I added use client at the top of my Navbar.tsx, it works fine.

1 Like