Skip to content

Commit

Permalink
improve code and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli committed Sep 28, 2024
1 parent 42b1e73 commit c2eb034
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/mui-material/src/Rating/Rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ function RatingItem(props) {
const isFocused = itemValue <= focus;
const isChecked = itemValue === ratingValueRounded;

const id = (name ? `${name}-` : '') + useId();
// "name" ensures unique IDs across different Rating components in React 17,
// preventing one component from affecting another. React 18's useId already handles this.
// Update to const id = useId(); when React 17 support is dropped.
// More details: https://github.com/mui/material-ui/issues/40997
const id = `${name}-${useId()}`;

const container = (
<RatingIcon
Expand Down

0 comments on commit c2eb034

Please sign in to comment.