-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[docs] Allow function prop to return undefined
#32766
Conversation
@m4theushw is it better to use |
@siriwatknp I didn't understand you. Do you mean to use |
@m4theushw I mean we can just update the diff --git a/packages/mui-material/src/Rating/Rating.d.ts b/packages/mui-material/src/Rating/Rating.d.ts
index 1eb262d4c4..667ee0aaeb 100644
--- a/packages/mui-material/src/Rating/Rating.d.ts
+++ b/packages/mui-material/src/Rating/Rating.d.ts
@@ -47,7 +47,7 @@ export interface RatingProps
* return `${value} Star${value !== 1 ? 's' : ''}`;
* }
*/
- getLabelText?: (value: number) => string;
+ getLabelText?: (value: number) => React.ReactNode;
/**
* If `true`, only the selected icon will be highlighted.
* @default false
|
@siriwatknp Replacing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good.
For context,
I also suspect that it should never be an empty string/null/undefined.
@m4theushw It could have been great to have an exact example on this PR. It's not clear to me why we need to support |
@oliviertassinari This PR was created to allow |
@m4theushw Thanks for the context: I see this approach used here as well: We might be able to argue that using only one of the two for the types and the docs could improve the DX too. Why? Because it would mean that developers don't have to choose between using export type GridRowHeightReturnValue = number | undefined | 'auto'; is a step forward. But then, it's a bit confusing for me. What does returning export type GridRowHeightReturnValue = number | 'props.rowHeight' | 'auto'; |
If a prop receives a function whose return has
undefined
, thenyarn docs:api
crashes with:This can be tested applying the diff below:
The reason for this change is because in mui/mui-x#4859 I added a prop to the DataGrid which can return
null
and other values. I can't addundefined
because the docs generator crashes.