-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add child function support to Link #605
Conversation
…with other components.
…with other components.
Thanks for the PR. Anyway, I didn't understand the real problem behind here. Could you send us a sample repo with the original issue? |
Have you also looked into the imperative routing API? |
Here is the simplest sample repo I could cook up with the original issue. I'm just trying to use React-Bootstrap's Navbar component, and it does not play nice with Next.js out of the box. I had a similar problem with React Router, but was able to work around it by using a child function. That's why I thought it'd be handy to add to Next.js. If there is a better way to achieve my simple goal, ignore my pull request. |
@rauchg Thanks for pointing me to imperative routing API. This code works:
|
Awesome @jkhoffman. We strive to keep parity between "manual" imperative APIs and their declarative JSX shorthand. |
I think I found a solution that allows the use of First create a component for passing the props around
Then in your navbar use |
…upgrade guide (vercel#606) * add dotenv to the configuration removal list in v2 upgrade guide * also mention now-env as part of the solution for replacing dotenv * Update pages/docs/v2/platform/upgrade-to-2-0.mdx Co-Authored-By: williamli <email@williamli.dev>
In my project, I'm using React Bootstrap for style/UI components. In my header, I use the NavItem component. But, that component is not aware of the Next.js router, which results in a server roundtrip for every click.
To fix this, I borrowed a concept from React Router and added support for child functions to Link. Here is how I use it in my project:
This allows me to inject the onClick from my router-aware Link to my non-router-aware NavItem.
Hope it's helpful.