Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

perf(button): memoize icon, label and badge rendering#8530

Open
sudheerchauhan452-lab wants to merge 2 commits into
primefaces:masterfrom
sudheerchauhan452-lab:perf/button-memoization
Open

perf(button): memoize icon, label and badge rendering#8530
sudheerchauhan452-lab wants to merge 2 commits into
primefaces:masterfrom
sudheerchauhan452-lab:perf/button-memoization

Conversation

@sudheerchauhan452-lab

@sudheerchauhan452-lab sudheerchauhan452-lab commented Apr 15, 2026

Copy link
Copy Markdown

Closes #8526

Summary

This PR improves the performance of the Button component by memoizing the rendering of icon, label, and badge using React.useMemo.

Changes

  • Memoized icon, label, and badge computations
  • Inlined helper logic to avoid hook dependency warnings
  • Ensured hooks are not conditionally called
  • Added proper dependency arrays

Benefits

  • Reduces unnecessary computations during re-renders
  • Improves performance in high-frequency rendering scenarios (e.g., lists, forms)
  • Aligns with React performance best practices
  • No breaking changes

Testing

  • Verified button rendering with:
    • icon changes
    • loading state
    • label updates
    • badge updates
  • Ensured no UI regressions

Notes

This change maintains full backward compatibility and does not alter the public API.

Optimize Button component by memoizing icon, label and badge computations using React.useMemo.

- Prevents unnecessary recalculations on re-renders
- Improves performance in high-frequency render scenarios
- Inlined helper logic to avoid hook dependency issues
- Maintains full backward compatibility"
@github-actions

Copy link
Copy Markdown

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

@melloware melloware added the Type: Performance Issue is performance or optimization related label Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Type: Performance Issue is performance or optimization related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enchancement: Memoize UI builders in Button

3 participants