[react-router-dom] navlink, renderMatches & matchRoutes #4425
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Other notes:
reviewing commit by commit should be easier:
drop outdated support of Navlink props
activeClassName
&activeStyle
also improve type className & style then add tests
cf. https://reactrouter.com/en/main/upgrading/v5#remove-activeclassname-and-activestyle-props-from-navlink-
Navlink prop
exact
renamed toend
cf. https://reactrouter.com/en/main/upgrading/v5#rename-navlink-exact-to-navlink-end
Navlink's
isActive
has been removed between versions 5 & 6 without notice:v5: https://v5.reactrouter.com/web/api/NavLink/isactive-func
latest: https://reactrouter.com/en/main/components/nav-link#navlink
Navlink accepts render prop
cf. https://reactrouter.com/en/main/components/nav-link#children
refactor
renderMatches
&matchRoutes
typesimprove types to make it more precise and more close to typescript definition
cf.
matchRoute https://github.com/remix-run/react-router/blob/d19c2c221c9f53b8273033f31b0ee94734719f47/packages/router/utils.ts#L374
renderRoutes https://github.com/remix-run/react-router/blob/d19c2c221c9f53b8273033f31b0ee94734719f47/packages/react-router/lib/components.tsx#L630