primefaces / primefaces/primereact
Enchancement: Memoize UI builders in Button
Open
@sudheerchauhan452-lab is already working on this.
Since Apr 15, 2026.
Type: Performance
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Problem
In the Button component, the helper functions createIcon, createLabel, and createBadge are executed on every render, regardless of whether their dependent props have changed.
While each computation is relatively small, this can lead to unnecessary recalculations in scenarios where the Button component re-renders frequently (e.g., in lists, forms, or state updates).
Suggested Improvement
Memoize the results of these helper functions using React.useMemo, based on their relevant dependencies.
Example:
const icon = React.useMemo(() => createIcon(), [props.icon, props.loading, props.iconPos]);
const label = React.useMemo(() => createLabel(), [props.label, props.children]);
const badge = React.useMemo(() => createBadge(), [props.badge]);
Benefits
- Reduces redundant computations on re-render
- Aligns with React performance best practices
- Improves efficiency in high-frequency render scenarios
- Maintains full backward compatibility
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.