[Tooltip] Performance issue when lots of tooltips are used in a table · Issue #27057 · mui/material-ui

PHOTO EMBED

Wed Nov 02 2022 10:10:04 GMT+0000 (Coordinated Universal Time)

Saved by @jacopo

import { useState } from 'react';
import Tooltip, { TooltipProps } from '@mui/material/Tooltip';

export default function CustomTooltip({ children, ...rest }: TooltipProps) {
    const [renderTooltip, setRenderTooltip] = useState(false);

    return (
        <div
            onMouseEnter={() => !renderTooltip && setRenderTooltip(true)}
            className="display-contents"
        >
            {!renderTooltip && children}
            {
                renderTooltip && (
                    <Tooltip {...rest}>
                        {children}
                    </Tooltip>
                )
            }
        </div>
    );
}
content_copyCOPY

https://github.com/mui/material-ui/issues/27057