Skip to content
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

Support Number Type for next/link children #37981

Closed
flyingSquirrel-dev opened this issue Jun 24, 2022 · 3 comments · Fixed by #38013
Closed

Support Number Type for next/link children #37981

flyingSquirrel-dev opened this issue Jun 24, 2022 · 3 comments · Fixed by #38013

Comments

@flyingSquirrel-dev
Copy link

Describe the feature you'd like to request

I think it would be better to support the number type for next/link children.
Can I open a PR to support it if it's okay with you? :)

Describe the solution you'd like

// packages/next/client/link.tsx
if (legacyBehavior && (typeof children === 'string' || typeof children === 'number')) {
  children = <a>{children}</a>
}

Describe alternatives you've considered

Add a condition to check the type of children

@SukkaW
Copy link
Contributor

SukkaW commented Jun 25, 2022

IMHO it is a bug (not a missing feature). I have opened PR #38013 to fix it.

@kodiakhq kodiakhq bot closed this as completed in #38013 Jun 25, 2022
kodiakhq bot pushed a commit that referenced this issue Jun 25, 2022
…38013)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes #37981.

When handling the legacy link behavior on the current version of Next.js, it only wraps single string child in `<a>` tag. The PR fixes the issue by also wrap single number child in `<a>` tag, too.
@flyingSquirrel-dev
Copy link
Author

@SukkaW Thanks for your PR.

I was about to create the PR to fix it, so I raised this issue to check if it is bug or not before creating PR.

I wish you would have asked first before taking this issue. I feel like my all efforts and time to find the bug have been wasted.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants