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

fix(button): Fixed Typescript error when using Next.js Link in the button as prop #1244

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

nigellima
Copy link
Collaborator

Summarize the changes made and the motivation behind them.
This PR fixes the Typescript error when the Next Link component was passed to the Button as prop.
The error is now fixed and the props inference of the component/element passed to the as prop still works properly

Reference related issues using # followed by the issue number.

fix #1002 fix #1107

`as` prop was throwing TS errors when using Next Link component. Now this correctly infers the type
from any component passed to the `as` prop

fix themesberg#1002 fix themesberg#1107
Copy link

vercel bot commented Jan 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 24, 2024 0:17am

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7461173) 99.54% compared to head (3c8b062) 97.38%.
Report is 190 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1244      +/-   ##
==========================================
- Coverage   99.54%   97.38%   -2.17%     
==========================================
  Files         163      216      +53     
  Lines        6621     9217    +2596     
  Branches      401      538     +137     
==========================================
+ Hits         6591     8976    +2385     
- Misses         30      241     +211     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SutuSebastian SutuSebastian merged commit a6698d4 into themesberg:main Jan 24, 2024
5 checks passed
abdulbasithqb pushed a commit to abdulbasithqb/flowbite-react that referenced this pull request Jan 31, 2024
…tton `as` prop (themesberg#1244)

* fix(button): correctly infer type from `as` prop

`as` prop was throwing TS errors when using Next Link component. Now this correctly infers the type
from any component passed to the `as` prop

fix themesberg#1002 fix themesberg#1107

* fix(dropdown-item): applied the generic types to DropdownItem and also wraps it with a forwardRef

* docs(button): removed now-unnecessary @ts-expect-error comments

* fix(button): replaced use of old genericForwardRef
abdulbasithqb pushed a commit to abdulbasithqb/flowbite-react that referenced this pull request Jan 31, 2024
…tton `as` prop (themesberg#1244)

* fix(button): correctly infer type from `as` prop

`as` prop was throwing TS errors when using Next Link component. Now this correctly infers the type
from any component passed to the `as` prop

fix themesberg#1002 fix themesberg#1107

* fix(dropdown-item): applied the generic types to DropdownItem and also wraps it with a forwardRef

* docs(button): removed now-unnecessary @ts-expect-error comments

* fix(button): replaced use of old genericForwardRef
@rnicholus
Copy link
Contributor

rnicholus commented Mar 12, 2024

This seems to have introduced some regressions. Why is the return type of Button now React.ReactNode instead of JSX.Element? Same question for Dropdown.Item.

This issue occurred previously. Reported in #962 and fixed in #974.

rnicholus added a commit to BigleafNetworks/flowbite-react that referenced this pull request Mar 14, 2024
…tem to JSX.Element

In themesberg#1244, the return type of Button and DropdownItem was changed to ReactNode. This is not an
acceptable return type for functional components. The correct return type is JSX.Element. This
change fixes the regression from that PR (introduced in v v0.7.3 A Also fixes  themesberg#962.

fix themesberg#962
rnicholus added a commit to BigleafNetworks/flowbite-react that referenced this pull request Mar 14, 2024
@github-actions github-actions bot mentioned this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button as a link error Button component as={Link} triggers typecheck error
3 participants