I am trying to show tooltips when the user selects a rating star with the following code, but the performance is very poor (it is a part of huge MUI components).
I am wondering if I can achieve the same effect with IconContainerComponent. Is that possible?
<Tooltip title={labels[ratingTooltipValue !== -1 ? ratingTooltipValue : 1]}>
<Box display="inline-block">
<Rating
value={parseInt(field.value, 10)}
onChange={(newValue) => {
field.onChange(newValue);
}}
precision={1}
size="small"
readOnly={viewMode}
onChangeActive={(event, newHover) => {
setRatingTooltipValue(newHover);
}}
/>
</Box>
</Tooltip>
Performance example
https://codesandbox.io/p/sandbox/priceless-feather-w3rrpf?file=%2Fdemo.tsx%3A12%2C18
EDIT I added a 2-second delay inside the onChangeActive and now it seems much better. As an alternative solution, can I use a custom tooltip inside the IconContainerComponent
Here is the answer
and the CSS file