Skip to content

Commit cff95f6

Browse files
committed
@fluent/react 0.12.0
1 parent d95ac26 commit cff95f6

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

fluent-react/CHANGELOG.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,100 @@
11
# Changelog
22

3+
## @fluent/react 0.12.0 (April 7, 2020)
4+
5+
- Migrate to TypeScript. (#458)
6+
7+
The source code of `@fluent/react` has been ported to TypeScript. The
8+
rewrite required a number of breaking changes to the public API, which
9+
are documented below.
10+
11+
#### Breaking Changes
12+
13+
- `<LocalizationProvider>` now accepts a single prop called `l10n` which
14+
must be an instance of a `ReactLocalization`. See [#461][] for the
15+
rationale behind this change.
16+
17+
```jsx
18+
// The old API
19+
<LocalizationProvider bundles={bundlesIterable}>
20+
<App />
21+
</LocalizationProvider>
22+
```
23+
24+
↑ becomes ↓
25+
26+
```jsx
27+
// The new API
28+
let l10n = new ReactLocalization(bundlesIterable);
29+
<LocalizationProvider l10n={l10n}>
30+
<App />
31+
</LocalizationProvider>
32+
```
33+
34+
If you'd like to use a custom markup parser you can pass it as the second
35+
argument to the `ReactLocalization` constructor:
36+
37+
```js
38+
let l10n = new ReactLocalization(bundlesIterable, parseMarkup);
39+
```
40+
41+
- The way variables and elements are passed to `<Localized>` has changed.
42+
See [#458][] for more information.
43+
44+
Rather than pass variables as `$`-prefixed props, you must now pass them
45+
explicitly as a dictionary to the `vars` prop.
46+
47+
```jsx
48+
// The old API
49+
<Localized id="hello" $userName="Alice">
50+
{"Hello, {$userName}!"}
51+
</Localized>
52+
```
53+
54+
↑ becomes ↓
55+
56+
```jsx
57+
// The new API
58+
<Localized id="hello" vars={{userName: "Alice"}}>
59+
{"Hello, {$userName}!"}
60+
</Localized>
61+
```
62+
63+
Rather than pass elements for the [React Overlays][] logic as regular
64+
props, you must now pass them explicitly as a dictionary to the `elems`
65+
prop.
66+
67+
```jsx
68+
// The old API
69+
<Localized id="privacy-policy" a={<a href="…" />}>
70+
{"Read the <a>Privacy Policy</a>."}
71+
</Localized>
72+
```
73+
74+
↑ becomes ↓
75+
76+
```jsx
77+
// The new API
78+
<Localized id="privacy-policy" elems={{a: <a href="…" />}}>
79+
{"Read the <a>Privacy Policy</a>."}
80+
</Localized>
81+
```
82+
83+
#### API Additions
84+
85+
- The `ReactLocalization` class is now exported and must be initialized
86+
manually for passing into `<LocalizationProvider>` (see above).
87+
88+
- The `LocalizedProps` interface describes the types of props passed to
89+
`<Localized>`.
90+
91+
- The `WithLocalizationProps` interface describes the types of extra props
92+
passed to components decorated with the `withLocalization` HOC.
93+
94+
[#461]: https://github.com/projectfluent/fluent.js/pull/461
95+
[#458]: https://github.com/projectfluent/fluent.js/pull/458
96+
[React Overlays]: https://github.com/projectfluent/fluent.js/wiki/React-Overlays
97+
398
## @fluent/react 0.11.1 (January 31, 2020)
499
5100
- Don't call `createParseMarkup` too eagerly. (#453)

fluent-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@fluent/react",
33
"description": "Fluent bindings for React",
4-
"version": "0.11.1",
4+
"version": "0.12.0",
55
"homepage": "https://projectfluent.org",
66
"author": "Mozilla <l10n-drivers@mozilla.org>",
77
"license": "Apache-2.0",

0 commit comments

Comments
 (0)