New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't be dependent on react-router-dom #93
Comments
Hi @KaiSpencer, Thanks for opening the issue. May I ask you for some more information?
I don't get it, maybe @tulup-conner could help us here since he is heavily working on the Sidebar component. But, if you are talking to remove dependency libraries I'm always interested. 👍 |
Hi @rluders Sure thing, the sidebar requires react-router, it uses a hook to determine the url and the Link component to handle navigation. This isn't something that every react application wants by default. I think client side routing should be opt in for the component In my scenario I use Nextjs with its own router and don't want to have to switch to client side routing just to use this component. MUI may be a good starting point to take some hints how to handle supporting various routing libraries. |
@KaiSpencer all right... I think that I got it., but please correct me if I'm wrong. The overall idea is to allow the sidebar component to receive a "router adapter" to use internally to generate the links. So the user can easily replace it in order to use the router that best fits his application. Something like this? It sounds like a good idea IMHO. |
@rluders Yeah, it could be as simple as optionally passing an override to the Link component. And rather than using react-router useLocation, use window.href.pathname instead for the current route. |
Yea I agree completely. It's already being used in another component so I added it thinking that was the intended way to go. I didn't think about the fact that react-router in Next takes on the role of client side routing. That is definitely not desirable. I'm spoiled by Remix. |
OK. So, I guess that we agree that remove the @KaiSpencer if you want to go ahead and submit a PR implementing this feature we gonna be happy to review it and accept. |
Is your feature request related to a problem? Please describe.
Im attempting to use the sidebar component, but useLocation is called internally to the component from react router. Additionally the react router Link component is used in each sidebar item.
Describe the solution you'd like
Ability to pass the current path directly to the component, potentially via the SidebarComponent context as one possible solution.
Describe alternatives you've considered
Use react router within my nextjs app, I would rather not use client side routing.
Additional context
Happy to contribute if an agreed direction by the maintainers is proposed.
Ideally react-router should be opt in rather than having to opt out in my eyes.
The text was updated successfully, but these errors were encountered: