Skip to content

Create NumberFormatter only if necessary #9127

@plesiecki

Description

@plesiecki

Provide a general summary of the issue here

Intl formatters creation is expensive and unnecessary creation should be avoided.

let formatter = useNumberFormatter(formatOptions);
if (!isIndeterminate && !valueLabel) {
let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
valueLabel = formatter.format(valueToFormat);
}

🤔 Expected Behavior?

Only create a NumberFormatter if you intend to use it.

�� Current Behavior

Sometimes a NumberFormatter instance of useProgressBar can be wasted.

let formatter = useNumberFormatter(formatOptions);
if (!isIndeterminate && !valueLabel) {
let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
valueLabel = formatter.format(valueToFormat);
}

💁 Possible Solution

#9128

🔦 Context

Minor perf improvement

🖥️ Steps to Reproduce

n/a

Version

latest

What browsers are you seeing the problem on?

Chrome, Firefox, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

n/a

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions