Dynamic Breadcrumbs Component for Ola Rides
In a complex application like Ola, users navigate through various screens and flows, from booking a ride to reviewing past trips or managing profiles. A clear navigational aid is crucial for a smooth user experience. Breadcrumbs provide users with a visual trail of their location within the application's hierarchy, enhancing discoverability and allowing them to quickly jump back to previous sections. This problem focuses on building a robust and reusable Breadcrumbs component.
Your task is to implement a Breadcrumbs React component that dynamically renders a navigation trail based on an array of path objects.
Breadcrumbs component: This component should accept a prop, paths, which is an array of objects. Each object in the paths array should have at least a label (string) and an optional path (string) representing the URL segment.
interface BreadcrumbItem {
label: string;
path?: string; // Optional path for the last item, or if it's not meant to be a link
}
paths array and render each item.>) between breadcrumb items.paths prop changes.path (you don't need to implement actual routing, just use <a> tags).<nav>, <ol>, <li>) and consider ARIA attributes where appropriate to enhance accessibility for screen readers.Breadcrumbs component renders correctly based on the paths prop.path property.>) is present between successive breadcrumb items.paths prop is changed dynamically.Constraints
paths array prop will always contain at least one BreadcrumbItem.path property for BreadcrumbItem will be a simple string (e.g., /home, /rides/current/details). You do not need to implement complex routing logic; simply use standard <a> tags.paths data.Breadcrumbs component.Loading editor...