This is the second beta release of React Intl v2!
There are no breaking changes between beta-1 and beta-2. This release fixes a couple of bugs, adds some new features/improvements, and adds 87 unit tests. The lower-level format API is now fully tested. The next step in the release process is to finish off the tests and update the docs on the website, at that time a Release Candidate will be cut. The expectation for the first RC release will be after the holidays.
Details and discussion: #162
$ npm install react-intl@next
New Features
Upgrade Guide
A v2 Upgrade Guide has been added to the repo. This guide focuses on the core aspects of upgrading and not on all the new features in v2. #162 has the high-level details and a long discussion on the all the changes v2.
See: #193
Faster <FormattedMessage>
and formatMessage()
Message formatting is a relatively expensive operation compare to a simple message lookup in an object. Most UI messages in apps are simple string without {placeholder}
s. Now, <FormattedMessage>
and its underlying formatMessage()
have a fast path for these simple strings that cued on whether or not values
are passed-in to fill the {placeholder}
s within the message.
The reason this optimization works is because of the message formatting fallback strategy. If a message does have a placeholder but not values
are passed, the message will fail to format and the raw string will be returned. This heuristic, whether or not values
were specified, is used to determine that the fast path can be taken when values
are absent. However, this optimization only occurs in production, in development messages will always be formatted so helpful warnings can be displayed when a message has placeholders but the values
are missing.
See: #233
Nested <IntlProvider>
Support
It's now easier to have nested <IntlProvider>
instances within a component tree. A common use case is for apps whose UIs are split among multiple packages, each with their own translated messages. These chunks of UI can now be wrapped with a nested <IntlProvider>
configured to only expose the translated message for that package's root component.
By default, a nested <IntlProvider>
will inherit from the <IntlProvider>
directly above it in the hierarchy, if one exists. This makes it easier to inherit configuration values like locale
without having to look it up.
See: #217
Babel 6 Support
React Intl's build has been completely rewritten using Babel 6 and Rollup. The dist/
build is now ~15% smaller, min + gzip.
babel-plugin-react-intl@2.0.0
has been released and it works with Babel 6. The 1.x version line of the plugin works Babel 5.
See: #230
Added WrappedComponent
Static to injectIntl()
Components
The component passed into injectIntl()
can now be referenced via the new WrappedComponent
static property on the returned component.
See: #219
Two New Examples
Bugfixes
- Fixed missing
return
ininjectIntl()
'sgetWrappedInstance()
method: #210 - Upgrade to
intl-format-cache@2.0.5
: #228