Build a Reusable Breadcrumbs Component
Breadcrumbs are a secondary navigation aid that helps users understand their location within a website or application's hierarchy. They provide a clear, clickable path back to higher-level pages, improving discoverability and overall user experience. For an L3 candidate, building a robust and accessible breadcrumbs component demonstrates an understanding of fundamental UI component design, prop handling, and accessibility best practices in React.
Your task is to implement a reusable Breadcrumbs React component.
Breadcrumbs.Breadcrumbs component should accept a prop named items, which will be an array of objects. Each object in the array will represent a segment of the path and should have the following structure:
interface BreadcrumbItem {
label: string; // The display text for the breadcrumb segment
href: string; // The URL path for the breadcrumb segment
}
BreadcrumbItem in the items array sequentially.<a> tag) using its href.<span> tag), indicating the current page, and should not be a clickable link.> or /) between each breadcrumb segment.href attribute is sufficient; no actual routing integration is needed).<nav> element with aria-label="Breadcrumb".aria-current="page" attribute.<ol>, <li>) are used.Breadcrumbs component is defined and rendered in App.tsx.items prop, adhering to the BreadcrumbItem interface.items except the last one are rendered as clickable links (<a> tags).item is rendered as non-clickable plain text (e.g., <span> tag).> or /) is displayed between breadcrumb segments.<nav aria-label="Breadcrumb"> element.aria-current="page" attribute.Constraints
href values provided in the items prop are valid paths, even if they don't lead to actual pages in this simulated environment.href attribute is sufficient.items props.Loading editor...