# Changelog ## [0.15.2](https://github.com/projectfluent/fluent.js/compare/@fluent/react@0.15.1...@fluent/react@0.15.2) (2023-08-01) - Allow user provided reportError function ([#619](https://github.com/projectfluent/fluent.js/issues/619)) ## [0.15.1](https://github.com/projectfluent/fluent.js/compare/@fluent/react@0.15.0...@fluent/react@0.15.1) (2023-05-27) - Update dependencies & example ([#612](https://github.com/projectfluent/fluent.js/pull/612)) ## [0.15.0](https://github.com/projectfluent/fluent.js/compare/@fluent/react@0.14.1...@fluent/react@0.15.0) (2023-03-13) - Drop Node.js v12 support, add v18 & latest to CI tests ([#607](https://github.com/projectfluent/fluent.js/pull/607)) - Add `getElement` method to ReactLocalization ([#595](https://github.com/projectfluent/fluent.js/pull/595)) - Update fluent-react/example to use latest Parcel ([#593](https://github.com/projectfluent/fluent.js/pull/593)) - Update dev dependencies to react@18 and jest@29 ## [@fluent/react 0.14.1](https://github.com/projectfluent/fluent.js/compare/@fluent/react@0.14.0...@fluent/react@0.14.1) (2021-12-21) - Add `.js` extension to imports ([#577](https://github.com/projectfluent/fluent.js/pull/577)) - Drop `prop-types` as a dependency ([#575](https://github.com/projectfluent/fluent.js/pull/575)) ## @fluent/react 0.14.0 (September 13, 2021) - Remove `"type": "commonjs"` from the package's root `package.json`, but add `"type": "module"` to the `esm/` directory. ([#556](https://github.com/projectfluent/fluent.js/pull/556), [#567](https://github.com/projectfluent/fluent.js/pull/567)) - Set Node.js 12 as the minimum supported version ([#557](https://github.com/projectfluent/fluent.js/pull/557)) - Provide better errors when components are mis-configured ([#549](https://github.com/projectfluent/fluent.js/pull/549)) ## @fluent/react 0.13.1 (Apr 7, 2021) - Allow the Localized component to have an array with one element in its children property (#541) ## @fluent/react 0.13.0 (July 2, 2020) - Add the `useLocalization` hook. (#467, #475) The hook can be used to get a reference to the current `ReactLocalization` instance, for example in order to format a translation with the imperative `getString` API. ```js let { l10n } = useLocalization(); alert(l10n.getString("hello")); ``` - Remove `compat.js` builds and compile everything to ES2018. (#472) TypeScript source code is now compiled to ES2018 files in the `esm/` directory. These files are then bundled into a single `index.js` UMD file without any further transpilation. The `compat.js` build (available as `@fluent/bundle/compat`) was removed. Please use your own transpilation pipeline if ES2018 is too recent for your project. Refer to https://github.com/projectfluent/fluent.js/wiki/Compatibility for more information. - Require `@fluent/bundle` 0.16.0 as peer dependency. In `@fluent/bundle` 0.16.0 `FluentArgument` was renamed to `FluentVariable`. ## @fluent/react 0.12.0 (April 7, 2020) - Migrate to TypeScript. (#458) The source code of `@fluent/react` has been ported to TypeScript. The rewrite required a number of breaking changes to the public API, which are documented below. #### Breaking Changes - `` now accepts a single prop called `l10n` which must be an instance of a `ReactLocalization`. See [#461][] for the rationale behind this change. ```jsx // The old API ``` ↑ becomes ↓ ```jsx // The new API let l10n = new ReactLocalization(bundlesIterable); ; ``` If you'd like to use a custom markup parser you can pass it as the second argument to the `ReactLocalization` constructor: ```js let l10n = new ReactLocalization(bundlesIterable, parseMarkup); ``` - The way variables and elements are passed to `` has changed. See [#458][] for more information. Rather than pass variables as `$`-prefixed props, you must now pass them explicitly as a dictionary to the `vars` prop. ```jsx // The old API {"Hello, {$userName}!"} ``` ↑ becomes ↓ ```jsx // The new API {"Hello, {$userName}!"} ``` Rather than pass elements for the [React Overlays][] logic as regular props, you must now pass them explicitly as a dictionary to the `elems` prop. ```jsx // The old API }> {"Read the Privacy Policy."} ``` ↑ becomes ↓ ```jsx // The new API }}> {"Read the Privacy Policy."} ``` #### API Additions - The `ReactLocalization` class is now exported and must be initialized manually for passing into `` (see above). - The `LocalizedProps` interface describes the types of props passed to ``. - The `WithLocalizationProps` interface describes the types of extra props passed to components decorated with the `withLocalization` HOC. [#461]: https://github.com/projectfluent/fluent.js/pull/461 [#458]: https://github.com/projectfluent/fluent.js/pull/458 [react overlays]: https://github.com/projectfluent/fluent.js/wiki/React-Overlays ## @fluent/react 0.11.1 (January 31, 2020) - Don't call `createParseMarkup` too eagerly. (#453) Fix a regression from 0.11.0 in which the default `FluentContext` value was an empty `ReactLocalization` which would call `createParseMarkup` to create its markup parser. In SSR, it's not desirable to call this function as it uses the `document` global. ## @fluent/react 0.11.0 (January 23, 2020) - Use the offical stable React Context API. (#406) `@fluent/react` used to use the [legacy React Context API](https://reactjs.org/docs/legacy-context.html). Thanks to @Gregoor, we now use the official [React Context API](https://reactjs.org/docs/context.html) instead. `@fluent/react` bundle size is now around 15% smaller (1.5 KB minified and gzipped). - Require React 16.8+. The switch to the new React Context API requires that we drop support for old versions of React, like 0.14 and 15. Additionally, `@fluent/react` uses hooks under the hood now, which require at least React 16.8. - Accept `@fluent/bundle` 0.15 as peer dependency. ## @fluent/react 0.10.0 (July 30, 2019) - Update to `@fluent/bundle` 0.14.0. This version of `@fluent/react` can be used with the new `FluentBundle` API released in `@fluent/bundle` 0.14.0. - Report formatting errors from `Localized` and `getString`. (#412) Formatting errors are now printed to the console. In the future, `@fluent/react` will allow finer-grained control over rpeorting errors. See #411. ## @fluent/react 0.9.0 (July 25, 2019) - Rename `fluent-react` to `@fluent/react`. - Rename the runtime dependency to `@fluent/sequence`. - Rename the peer dependency to `@fluent/bundle`. ## fluent-react 0.9.0 (July 25, 2019) - Deprecate `fluent-react` in favor of `@fluent/react`. ## fluent-react 0.8.5 (July 25, 2019) - Accept `fluent` 0.13.x as a peer dependency. - Fix the rendering of empty ``. (#378) ## fluent-react 0.8.4 (March 29, 2019) - Accept `fluent` 0.11.x and 0.12.x as a peer dependency. ## fluent-react 0.8.3 (December 13, 2018) - Accept `fluent` 0.10.x as a peer dependency. ## fluent-react 0.8.2 (October 25, 2018) - Allow `` with no children elements. (#230) It's now possible to use string literals as children to ``. Previously, the string would need to be wrapped in a `` or some other element. Thanks to @blushingpenguin for this contribution! ``` String fallback. ``` - Accept `fluent` 0.9.x as a peer dependency. - Only format attributes defined in ``. A tiny optimization to avoid formatting attributes found in the localization which would be rejected by the sanitization logic in `` anyways. ## fluent-react 0.8.1 (August 28, 2018) - Change the `fluent` peer dependency to 0.8.x. Pin down the version of the `fluent` peer dependency to 0.8.x in case there are any breaking API changes in future its versions. ## fluent-react 0.8.0 (August 21, 2018) - Rename the `messages` prop to `bundles`. (#222) `` now expects an iterable of `FluentBundles` to be passed as the `bundles` prop, rather than `messages`. - Allow custom `parseMarkup` functions. (#233) By default, `fluent-react` uses a `