Skip to content

fix: prevent unnecessary state updates in Tooltip by checking for value changes#8525

Merged
melloware merged 1 commit intoprimefaces:masterfrom
mustafajw07:refactor/8524-prevent-re-render
Apr 11, 2026
Merged

fix: prevent unnecessary state updates in Tooltip by checking for value changes#8525
melloware merged 1 commit intoprimefaces:masterfrom
mustafajw07:refactor/8524-prevent-re-render

Conversation

@mustafajw07
Copy link
Copy Markdown
Contributor

Defect Fixes / Small Enhancements

Fixes #8524

Describe the changes:
In the Tooltip component, the setPositionState and setClassNameState functions within the useUpdateEffect hook were being invoked unconditionally every time the tooltip became visible.

Although React internals typically bail out of re-renders when the new state precisely matches the old state, invoking the setters unconditionally still incurs slight overhead by adding unnecessary calls to React's state update queue.

This PR implements a minor micro-optimization by adding explicit if checks:

if (position !== positionState) {
    setPositionState(position);
}

if (classname !== classNameState) {
    setClassNameState(classname);
}

@melloware melloware merged commit f1dc3ca into primefaces:master Apr 11, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Prevent redundant state setter calls in Tooltip component

2 participants