react-intl v3.2.0 Release Notes
Release Date: 2019-09-04 // over 4 years ago-
๐ Bug Fixes
- ๐ fix tests & add corresponding formatToParts fns (855e272)
๐ Features
extend numberformat to unified (#1462) (a7f2104)
๐ฆ Currently this is part of Unified NumberFormat which is stage 3. We've provided a polyfill here andreact-intl
types allow users to pass in a sanctioned unit. For example:<FormattedNumbervalue={1000}style="unit"unit="kilobyte"unitDisplay="narrow"/>
<span>1,000kB</span>
<FormattedNumbervalue={1000}unit="fahrenheit"unitDisplay="long"style="unit"/>
<span>1,000 degrees Fahrenheit</span>
โ add support for formatToParts (e8167f3)
introduce Parts component (a1b5ff1), closes #1048
๐ This component provides more customization toFormattedNumber/Date/Time
by allowing children function to have access to underlying parts of the formatted date. The available parts are listed here
Props:
props: NumberFormatOptions & { value: number, format: string, children: (parts: Intl.NumberFormatPart[]) =\> ReactElement, };
Example:
\<FormattedNumberParts value={1000}\> {parts =\> ( \<\> \<b\>{parts[0].value}\</b\> {parts[1].value} \<small\>{parts[2].value}\</small\> \</\> )}\</FormattedNumberParts\> \<b\>1\</b\>,\<small\>000\</small\>