ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
34 lines • 994 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSetLocale = void 0;
var useLocaleState_1 = require("./useLocaleState");
/**
* Set the current locale in the I18nContext and re-render the app when the locale changes.
*
* @example
*
* import { useSetLocale } from 'react-admin';
*
* const availableLanguages = {
* en: 'English',
* fr: 'Français',
* }
* const LanguageSwitcher = () => {
* const setLocale = useSetLocale();
* return (
* <ul>{
* Object.keys(availableLanguages).map(locale => {
* <li key={locale} onClick={() => setLocale(locale)}>
* {availableLanguages[locale]}
* </li>
* })
* }</ul>
* );
* }
*/
var useSetLocale = function () {
var _a = (0, useLocaleState_1.useLocaleState)(), setLocale = _a[1];
return setLocale;
};
exports.useSetLocale = useSetLocale;
//# sourceMappingURL=useSetLocale.js.map
;