Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

NavBar as={Link} (next/link; next.js) doesn't collapses the NavBar.Collapse #1037

Open
Labels
Milestone
@zurcacielos

Description

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

When I do a
import Link from "next/link";
<Navbar.Collapse >
<Navbar.Link as={Link} active={pathname == "/privacy"} href="/privacy">

Privacy Policy


</Navbar.Link>
</Navbar.Collapse >

I'm expecting the navbar to collapse. I use the Link from next/link because Next.js downloads those links in the background and do optimizations.

I also tried
const [open, setOpen] = useState(false);

<Navbar.Link as={Link} onClick={() => setOpen(false)} active={pathname == "/privacy"} href="/privacy">

Privacy Policy


</Navbar.Link>

but it doesn't work.

Context

https://nextjs.org/docs/pages/api-reference/components/link

is a React component that extends the HTML element to provide prefetching and client-side navigation between routes. It is the primary way to navigate between routes in Next.js.

Any help appreciated 🙌

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /