#I get this error when trying to use NavigationMenu from Shadcn in my project(continued in replies)

26 messages ยท Page 1 of 1 (latest)

bronze lintelBOT
#

๐Ÿ”Ž This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

๐Ÿ•ต๏ธ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

โœ… You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

flat summit
#



import {
    NavigationMenu,
    NavigationMenuContent,
    NavigationMenuIndicator,
    NavigationMenuItem,
    NavigationMenuLink,
    NavigationMenuList,
    NavigationMenuTrigger,
    navigationMenuTriggerStyle,
    NavigationMenuViewport,
} from "@/components/ui/navigation-menu";
import Link from "next/link";

export default function Home() {
    return (
        <div>
            <NavigationMenuItem>
                <Link href="#" legacyBehavior passHref>
                    <NavigationMenuLink
                        className={navigationMenuTriggerStyle()}
                    >
                        Documentation
                    </NavigationMenuLink>
                </Link>
            </NavigationMenuItem>
        </div>
    );
}
#

this was the code initially, after a reddit user suggest using the 'use client' directive at the top, i still got an error:

pearl nebula
#

That might be because of not having a "use client" at top

flat summit
#

right

pearl nebula
#

Where is the <NavigationMenu>?

flat summit
#

i think i figured out where i went wrong

#

yes thats the issue ๐Ÿ˜“

#

i just got the code to work

pearl nebula
flat summit
#

could you please explain how the use client directive changed things?

pearl nebula
#

The navigation menu might be using context or something. I haven't used that from shadcn

flat summit
#

never mind i tried it without use client and it still worked

#

the whole thing was becuase of a syntax (skill) issue

pearl nebula
#

Yeah i guess NavigationMenu takes care of the context provider abstraction and everything idk

#

I havent used that nav menu

pearl nebula
#

But since its fixed. Mark the answer as resolved

flat summit
#

well thank you anyways, this has been bothering me for a few days now

flat summit
#

i hit close post, do i need to do anything else

#

how do i mark as resolved ๐Ÿฅน ๐Ÿ”ซ

pearl nebula
flat summit
#

thank you