Skip to content

Commit f1dc3ca

Browse files
authored
fix: prevent unnecessary state updates in Tooltip by checking for value changes (#8525)
1 parent 75bdea5 commit f1dc3ca

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

components/lib/tooltip/Tooltip.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,14 @@ export const Tooltip = React.memo(
463463
const position = getPosition(currentTargetRef.current);
464464
const classname = getTargetOption(currentTargetRef.current, 'classname');
465465

466-
setPositionState(position);
467-
setClassNameState(classname);
466+
if (position !== positionState) {
467+
setPositionState(position);
468+
}
469+
470+
if (classname !== classNameState) {
471+
setClassNameState(classname);
472+
}
473+
468474
updateTooltipState(position);
469475

470476
bindWindowResizeListener();

0 commit comments

Comments
 (0)