feat(breadcrumb): render breadcrumbs from the hook

This commit is contained in:
RadoslavDimchev 2024-04-26 17:21:21 +03:00 committed by Emil Ivanichkov
parent 08e95fdb47
commit 16f9280354
1 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,14 @@
import { XStack } from 'tamagui' import { XStack } from 'tamagui'
import useBreadcrumbs, { BreadcrumbsRoute } from 'use-react-router-breadcrumbs'
import { NavLink } from 'react-router-dom'
import BreadcrumbElement from './BreadcrumbElement' import BreadcrumbElement from './BreadcrumbElement'
import {
MANAGE_VALIDATOR_SUB_PATHS,
PATHS,
VALIDATOR_ONBOARDING_SUB_PATHS,
} from '../../../constants'
const CustomPropsBreadcrumb = ({ someProp }: any) => <span>{someProp}</span> const CustomPropsBreadcrumb = ({ someProp }: any) => <span>{someProp}</span>
const routes = [ const routes = [
@ -75,14 +84,14 @@ const routes = [
] ]
const Breadcrumb = () => { const Breadcrumb = () => {
const breadcrumbs = useBreadcrumbs(routes as BreadcrumbsRoute<string>[])
return ( return (
<XStack space={'$2'} alignItems="center"> <XStack space={'$2'} alignItems="center">
{breadcrumbList.map((element, index) => ( {breadcrumbs.map(({ match, breadcrumb }) => (
<BreadcrumbElement <NavLink key={match.pathname} to={match.pathname}>
element={element} {breadcrumb}
isLastElement={index === breadcrumbList.length - 1} </NavLink>
/>
))} ))}
</XStack> </XStack>
) )