Updated profile settings. Refactored locale saving.

This commit is contained in:
Mike Cao 2020-09-17 00:17:11 -07:00
parent 814589f6a5
commit 7f598fa84d
9 changed files with 82 additions and 30 deletions

View file

@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React from 'react';
import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux';
import { useStore } from 'redux/store';
@ -9,17 +9,10 @@ import 'styles/bootstrap-grid.css';
import 'styles/index.css';
const Intl = ({ children }) => {
const [locale, setLocale] = useLocale();
const [locale] = useLocale();
const Wrapper = ({ children }) => <span className={locale}>{children}</span>;
useEffect(() => {
const saved = localStorage.getItem('locale');
if (saved) {
setLocale(saved);
}
});
return (
<IntlProvider locale={locale} messages={messages[locale]} textComponent={Wrapper}>
{children}