Replies: 1 comment 1 reply
-
|
Hallo @yinken, das sollte, wie folgt schon gehen: import React from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { KolBreadcrumb } from '@public-ui/react';
export const IconBreadcrumb: React.FC = () => {
const navigate = useNavigate();
const location = useLocation();
const createNavigateHandler = (path: string) => ({
onClick: (event: Event) => {
event.preventDefault();
navigate(path);
},
});
const breadcrumbLinks = [
{
_label: 'Homepage',
_icons: 'codicon codicon-home',
_hideLabel: true, // Nur Icon anzeigen
_href: '/',
_on: createNavigateHandler('/'),
},
{
_label: 'Produkte',
_href: '/products',
_on: createNavigateHandler('/products'),
},
{
_label: 'Details',
// Letzter Link ohne onClick Handler (current page)
_href: location.pathname,
},
];
return (
<KolBreadcrumb
_label="Breadcrumb mit Icons"
_links={breadcrumbLinks}
/>
);
};Wichtige Punkte
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
<KolBreadcrumbs />verwendet native html Tags für das rendern von Links<Link />Komponenten oder Methoden wie navigate("/home") für die NavigationWarum ist dies wichtig?
Das "normale" Verhalten beim Klick auf einen -Tag führt im schlimmsten Fall dazu, dass...
Proposal
<Link />Komponente von react-routerBeta Was this translation helpful? Give feedback.
All reactions