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

[BUG] - Button as Link Produces onClick Deprecation Warning #4493

Closed
briansokol opened this issue Jan 4, 2025 · 1 comment · Fixed by #4497
Closed

[BUG] - Button as Link Produces onClick Deprecation Warning #4493

briansokol opened this issue Jan 4, 2025 · 1 comment · Fixed by #4497
Labels
🐛 Type: Bug Something isn't working

Comments

@briansokol
Copy link

NextUI Version

2.6.10

Describe the bug

When using a Link component polymorphically as a button with only an href (<Button as={Link} href="/">), the app will produce a warning that says [Next UI] [useLink]: onClick is deprecated, please use onPress instead. This happens even when an onClick handler has not been provided directly on the button. Presumably the Button is using the Link's onClick handler internally.

I saw some previous bugs where this was already fixed (#3196, for example), but in that case, an onPress handler was being provided. In this case, I'm only providing an href.

Your Example Website or App

https://codesandbox.io/p/sandbox/next-ui-button-as-link-reproduction-zn6jc7

Steps to Reproduce the Bug or Issue

  1. Open the provided CodeSandbox.
  2. Open the dev tools console.
  3. Click the button that says "Click me".
  4. Observe the warning that is printed.
  5. You can see in the source code for App.tsx that the onClick handler is not being used.

Expected behavior

The button still works as usual, presumably using the internal onClick handler. I would expect it to use the internal onPress handler instead, and to not print the warning.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants