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

[Base][useButton] Allow useButton params to be completely optional #36922

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Apr 18, 2023

Closes #36879

@mj12albert mj12albert added component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Apr 18, 2023
@mui-bot
Copy link

mui-bot commented Apr 18, 2023

Netlify deploy preview

https://deploy-preview-36922--material-ui.netlify.app/

Bundle size report

Details of bundle changes

Generated by 🚫 dangerJS against 726a06f

@mj12albert mj12albert changed the title [Base][useButton] [Base][useButton] Allow useButton params to be completely optional Apr 18, 2023
@mj12albert mj12albert marked this pull request as ready for review April 18, 2023 09:10
@mj12albert mj12albert force-pushed the 36879-basebutton-allow-usebutton-parameters-to-be-completely-optional branch from c2bdf6a to 4cd72c9 Compare April 18, 2023 09:11
@@ -20,7 +20,7 @@ import { EventHandlers } from '../utils/types';
*
* - [useButton API](https://mui.com/base/api/use-button/)
*/
export default function useButton(parameters: UseButtonParameters): UseButtonReturnValue {
export default function useButton(parameters?: UseButtonParameters): UseButtonReturnValue {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be safer to specify it as:

Suggested change
export default function useButton(parameters?: UseButtonParameters): UseButtonReturnValue {
export default function useButton(parameters: UseButtonParameters = {}): UseButtonReturnValue {

This way, parameters will always be defined inside the body. Plus, it's shorter :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right ~ I totally overcomplicated this 😅

@mj12albert mj12albert force-pushed the 36879-basebutton-allow-usebutton-parameters-to-be-completely-optional branch from 4cd72c9 to 726a06f Compare April 18, 2023 14:12
@mj12albert mj12albert requested review from michaldudak and a team April 18, 2023 15:59
@mj12albert mj12albert merged commit 3d92241 into mui:master Apr 21, 2023
@mj12albert mj12albert deleted the 36879-basebutton-allow-usebutton-parameters-to-be-completely-optional branch April 21, 2023 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Base][Button] Allow useButton parameters to be completely optional
4 participants