Skip to content

Commit ae12bd5

Browse files
committed
fix: [Price] fallback for Intl.Numberformat.prototype.formatToParts
`formatToParts` return `undefined` on Android 8.1-
1 parent df43dd4 commit ae12bd5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/Price/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ const canFormat =
1515

1616
export const Price = React.forwardRef<HTMLDivElement, PriceProps>((props, ref) => {
1717
const { className, price, currency, locale, original, ...other } = props;
18-
let parts = [];
18+
let parts: any[] | void = [];
1919

2020
if (locale && currency && canFormat) {
2121
parts = new Intl.NumberFormat(locale, { style: 'currency', currency }).formatToParts(price);
2222
} else {
23+
parts = undefined;
24+
}
25+
26+
if (!parts) {
2327
const decimal = '.';
2428
const [integer, fraction] = `${price}`.split(decimal);
2529
parts = [

0 commit comments

Comments
 (0)