Closed oscartbeaumont closed 1 month ago
Latest commit: 68f50fde939405d8cd98310a0cfda953887181c7
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Turns out useCurrentMatches
is exactly this. I don't know how I missed it.
This PR adds a new
useMatches
hook which exposes the router's matches.Usecase
I think this is very useful for implementing a breadcrumb system.
Our pages have something along the lines of:
and then with the
useMatches
hook this PR implements, our breadcrumb component can be implemented as such:We are actively using these changes in our codebase and it would be really nice to upstream these changes so we don't require a fork. The codebase is open source if it provides more context to our usage. The Breadcrumb component and an example
route export
.Prior Art
React Router has a similar feature useMatches. These docs even showcase a Breadcrumb system similar to what I show above.