How to make breadcrumb item client-side navigation as next/link instead of browser routing #621
-
| I am using this library for my NextJS project. I am touching Breadcrumb component but seems like it is browser routing which mean it refresh full page. What can I do to make it route as next/link? |
Beta Was this translation helpful? Give feedback.
Answered by connorlanigan Jan 9, 2023
Replies: 1 comment
-
| The Breadcrumb component provides an You can combine them like this: import BreadcrumbGroup from "@cloudscape-design/components/breadcrumb-group"; import { useRouter } from 'next/router'; function MyApp() { const router = useRouter(); return ( <BreadcrumbGroup items={[ { text: 'System', href: '#' }, { text: 'Components', href: '#components' }, { text: 'Breadcrumb group', href: '#components/breadcrumb-group', }, ]} ariaLabel="Breadcrumbs" onFollow={event => { event.preventDefault(); router.push(event.detail.href) }} /> ); } |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by hiimnhan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
The Breadcrumb component provides an
onFollowevent that you can use to perform the client-side navigation.NextJS provides the
useRouterhook, which has apushmethod for this use case.You can combine them like this: