-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#65 Improve Intl utilities & extend intlDictionary
- Loading branch information
Felix Beceic
committed
Apr 24, 2023
1 parent
7a4bedd
commit 9014432
Showing
4 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import * as React from "react"; | ||
|
||
import { IntlContext } from "./IntlProvider"; | ||
import { IntlContext, IntlContextType } from "./IntlProvider"; | ||
|
||
export function useIntlContext() { | ||
export function useIntlContext(returnDefault?: boolean) { | ||
const context = React.useContext(IntlContext); | ||
|
||
if (!context) { | ||
if (!context && !returnDefault) { | ||
return undefined; | ||
} | ||
|
||
if (!context && returnDefault) { | ||
return { lang: "en" } as IntlContextType; | ||
} | ||
|
||
return context; | ||
} |