Skip to content

perf: memoize icon, label, and badge rendering in Button component to prevent unnecessary re-renders#8527

Closed
mustafajw07 wants to merge 1 commit intoprimefaces:masterfrom
mustafajw07:refactor/8526-Memoize-button-builder
Closed

perf: memoize icon, label, and badge rendering in Button component to prevent unnecessary re-renders#8527
mustafajw07 wants to merge 1 commit intoprimefaces:masterfrom
mustafajw07:refactor/8526-Memoize-button-builder

Conversation

@mustafajw07
Copy link
Copy Markdown
Contributor

Closes #8526

Defect Fixes

This PR improves the performance of the Button component by memoizing the results of createIcon, createLabel, and createBadge.

Currently, these helper functions are executed on every render, even when their dependent props do not change. This may lead to unnecessary recalculations in scenarios where the Button component re-renders frequently.

💡 Changes
Wrapped createIcon, createLabel, and createBadge with React.useMemo
Added appropriate dependency arrays based on relevant props

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.

Enchancement: Memoize UI builders in Button

1 participant