I have a requirement to display currency without decimals. We want the currency decorator ($), and the commas and spaces, as dictated by the locale, but no decimals.
I've tried the maximumFractionDigits set to 0. That works, but removes the commas and currency decorator.
Also, I have not been able to replicate the example in the docs at https://github.com/yahoo/react-intl/wiki/API#number-formatting-apis:
formatNumber(1000, {style: 'currency', currency: 'USD'}); // $1,000
I get $1,000.00.
Thanks for your help.
Turns out you need to specify both minimum and maximum fraction digits, like so:
formatNumber(1000, {style: 'currency', currency: 'USD',
minimumFractionDigits: 0, maximumFractionDigits: 0}); // $1,000
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With