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 a Link (Polymorphic) throws deprecation warning #1423

Closed
phev8 opened this issue Aug 17, 2023 · 5 comments · Fixed by #1432
Closed

[BUG] - Button as a Link (Polymorphic) throws deprecation warning #1423

phev8 opened this issue Aug 17, 2023 · 5 comments · Fixed by #1432
Assignees
Labels

Comments

@phev8
Copy link

phev8 commented Aug 17, 2023

NextUI Version

v2.0.22

Describe the bug

When using a Button as a link (as showed in the documentation), I get a deprecation warning:

onClick is deprecated, please use onPress

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

export default function App() {
  return (
    <Button
      href="https://github.com/nextui-org/nextui"
      as={Link}
      color="primary"
      showAnchorIcon
      variant="solid"
    >
      Button Link
    </Button>
  );
}

Expected behavior

The button should behave as a link and navigate to the next page without depreciation warning.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

@phev8 phev8 added the 🐛 Type: Bug Something isn't working label Aug 17, 2023
@phev8 phev8 changed the title [BUG] - Button as a Link (Polymorphic) throw deprecation warning [BUG] - Button as a Link (Polymorphic) throws deprecation warning Aug 17, 2023
@jrgarciadev
Copy link
Member

This warning is intentional, please use onPress instead of onClick.

here's why we use onPress:

https://react-spectrum.adobe.com/blog/building-a-button-part-1.html

@phev8
Copy link
Author

phev8 commented Aug 17, 2023

I saw this, but I don't use onClick the Link component of NextUI does, doesn't it?
Or maybe just the documentation is misguiding in this place on how to implement a link that looks like a button?

@jrgarciadev
Copy link
Member

Oh got it!, I'll reopen this then, thanks!

@jrgarciadev jrgarciadev reopened this Aug 17, 2023
@phev8
Copy link
Author

phev8 commented Aug 17, 2023

Thank you! Appreciate the great work
Also I just noted this issue, in case it would lead to issues in future, right now, it seems to work apart from the warning.

@camcam2605
Copy link
Contributor

@jrgarciadev because onClick existed in the button props before it passed to the Link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants