Describe the enhancement
In the Tooltip component's useUpdateEffect hook (which responds to visibleState changes), the setPositionState and setClassNameState functions are currently called unconditionally whenever the tooltip becomes visible.
While React's useState internal bails out of re-rendering if the new value matches the current state, invoking these setter functions unconditionally still adds slight overhead by adding to React's state queue.
This enhancement explicitly checks if the new position or classname values are different from the current positionState and classNameState before calling their respective setters.
Expected behavior
The component should only call setPositionState(position) and setClassNameState(classname) when the values actually differ from the currently active state, slightly optimizing rendering logic and preventing unnecessary operations.
Describe the enhancement
In the
Tooltipcomponent'suseUpdateEffecthook (which responds tovisibleStatechanges), thesetPositionStateandsetClassNameStatefunctions are currently called unconditionally whenever the tooltip becomes visible.While React's
useStateinternal bails out of re-rendering if the new value matches the current state, invoking these setter functions unconditionally still adds slight overhead by adding to React's state queue.This enhancement explicitly checks if the new
positionorclassnamevalues are different from the currentpositionStateandclassNameStatebefore calling their respective setters.Expected behavior
The component should only call
setPositionState(position)andsetClassNameState(classname)when the values actually differ from the currently active state, slightly optimizing rendering logic and preventing unnecessary operations.