icd2k3 / use-react-router-breadcrumbs

tiny, flexible, hook for rendering route breadcrumbs with react-router v6
https://stackblitz.com/edit/github-fiw8uj?file=src/App.tsx
MIT License
261 stars 23 forks source link

Navigation Feature Suggestion #65

Closed LouisMuriuki closed 2 years ago

LouisMuriuki commented 2 years ago

Nice library you have here however, I would suggest to implement a feature whereby navigation takes place on breadcrumb click. I didnt see that in the documentation but it would be great to have.

icd2k3 commented 2 years ago

Hi @LouisMuriuki - I wanted to keep the library un-opinionated about what link components to use, but if you check the Advanced Example it shows how to wrap the breadcrumbs in a NavLink component from react-router.

{breadcrumbs.map(({
  match,
  breadcrumb
}) => (
  <NavLink to={match.pathname}>{breadcrumb}</NavLink>
))}

Using a NavLink is probably the most popular option, but by keeping it flexible users can pick whatever link component they want

LouisMuriuki commented 2 years ago

Okay I hadn't seen that, implemented that in my project and it works just fine👍