-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui][Rating] Add
component
prop (#44199)
- Loading branch information
Showing
6 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import { expectType } from '@mui/types'; | ||
import Rating from '@mui/material/Rating'; | ||
|
||
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = | ||
function CustomComponent() { | ||
return <div />; | ||
}; | ||
|
||
const children: React.ReactNode = <div />; | ||
|
||
function RatingTest() { | ||
return ( | ||
<div> | ||
<Rating /> | ||
<Rating precision={0.5} /> | ||
|
||
<Rating>{children}</Rating> | ||
<Rating | ||
onChange={(event, value) => { | ||
expectType<number | null, typeof value>(value); | ||
expectType<React.SyntheticEvent, typeof event>(event); | ||
}} | ||
/> | ||
|
||
<Rating | ||
component="a" | ||
href="test" | ||
onClick={(event) => { | ||
expectType<React.MouseEvent<HTMLAnchorElement, MouseEvent>, typeof event>(event); | ||
}} | ||
/> | ||
<Rating component={CustomComponent} stringProp="test" numberProp={0} /> | ||
{/* @ts-expect-error missing stringProp and numberProp */} | ||
<Rating component={CustomComponent} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters