We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f58ae6 commit 69ea517Copy full SHA for 69ea517
fluent-react/src/useTranslate.ts
@@ -2,26 +2,13 @@ import { useContext } from "react";
2
import { FluentContext } from "./context";
3
import { ReactLocalization } from "./localization";
4
5
-// Implementation of null object pattern for ReactLocalization
6
-const fallbackL10n: ReactLocalization = {
7
- getString: id => id,
8
- getBundle: () => null,
9
- bundles: [],
10
- parseMarkup: null,
11
- reportError: () => undefined,
12
-};
13
-
14
/*
15
* The `useTranslate` hook returns the FluentContext
16
*/
17
type useTranslate = () => { l10n: ReactLocalization }
18
export const useTranslate: useTranslate = () => {
19
const l10n = useContext(FluentContext);
20
21
- if (!l10n) {
22
- return { l10n: fallbackL10n };
23
- }
24
25
return { l10n };
26
};
27
0 commit comments