Skip to content

Commit

Permalink
[TouchRipple] perf: avoid calling clearTimeout() (#37512)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk committed Jun 21, 2023
1 parent a91427e commit 6167b6a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/mui-material/src/ButtonBase/TouchRipple.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ const TouchRipple = React.forwardRef(function TouchRipple(inProps, ref) {
const ignoringMouseDown = React.useRef(false);
// We use a timer in order to only show the ripples for touch "click" like events.
// We don't want to display the ripple for touch scroll events.
const startTimer = React.useRef(null);
const startTimer = React.useRef(0);

// This is the hook called once the previous timeout is ready.
const startTimerCommit = React.useRef(null);
const container = React.useRef(null);

React.useEffect(() => {
return () => {
clearTimeout(startTimer.current);
if (startTimer.current) {
clearTimeout(startTimer.current);
}
};
}, []);

Expand Down

0 comments on commit 6167b6a

Please sign in to comment.