You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After # is merged, we'll have the ability to use react-router links using our Link component, but there are probably some good use cases coming up to use NavLinks too.
Well this took some experimentation, but we got there. Allows `Link` to
use a `isRouterLink` prop to convert them to `react-router` links with
minimal hassle.
## Changes
- add `react-router-dom` as an external dependency in the vite config,
since `react-router` needs its links to share the same instance of the
library to work. Works in concert [with this
change](https://github.com/cfpb/sbl-frontend/compare/198-integrate-react-router-links?expand=1#diff-6a3b01ba97829c9566ef2d8dc466ffcffb4bdac08706d3d6319e42e0aa6890ddR26-R28)
in `sbl-frontend`. What a pain this was. (Also, I added a maybe missing
`react-dom` from the `optimizeDeps.exclude` array for good measure)
- add a `isRouterLink` prop that switches `Link` to using `react-router`
Links
- fixes some Typescript errors
- adds a story for `isRouterLink` prop called "Link using React Router
Link"
## How to test this PR
1. Does the `isRouterLink` story "Link using React Router Link" render
without errors?
## Screenshots
![Screenshot 2024-01-29 at 11 15 16
PM](https://github.com/cfpb/design-system-react/assets/19983248/a3c9e483-945c-423c-9efa-1bf08bd8b5cd)
## Notes
- I could have also added a `NavLink` option, but I don't think we have
a use case for it since we have some similar logic built out already. I
made [a ticket for
it](#293), in case we
want to add it in.
- Enables this PR on sbl-frontend:
cfpb/sbl-frontend#201
After # is merged, we'll have the ability to use
react-router
links using ourLink
component, but there are probably some good use cases coming up to useNavLinks
too.Current behavior
Link
only supportsreact-router
Links
Expected behavior
Link
supportsreact-router
Links
andNavLinks
Notes
The text was updated successfully, but these errors were encountered: