Menubar item with next/link

UI Components for React
Post Reply
Mic
Posts: 18
Joined: 27 Sep 2010, 15:59

18 Sep 2020, 07:52

Hi...

can someone give me a hint please, how I could use next/link in a menubar item to switch a page? The window.location works but it will always reload the complete frame and a <Link href='/machines' /> would be much better.

{
label: 'Machines',
icon: 'pi pi-desktop',
command: () => { window.location.href = "/machines"; }
}

BTW: Is it possible to add a "rendered" property like in primefaces?

Best regards,
Mic

Mic
Posts: 18
Joined: 27 Sep 2010, 15:59

24 Sep 2020, 10:06

Hi...

I found a solution for my problem. The "next/link" is not needed, I simply use "next/router" instead and the complete page is not reloading anymore:

import Router from 'next/router'
...

const items = [
...
{
label: 'Machines',
icon: 'pi pi-desktop',
command: () => { Router.push("/machines"); },
}

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

10 Oct 2020, 20:55

Hi,

Thanks a lot for the update! Maybe, a render method can be added to Menuitem API to return JSX element. Good feedback!

Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests