Skip to content

Commit

Permalink
chore(frontend): add useEffect to _app for translate
Browse files Browse the repository at this point in the history
  • Loading branch information
gangjun06 committed Dec 26, 2022
1 parent 991e4b7 commit cfea0dc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions frontend/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ config.autoAddCss = false;
const App = ({ Component, pageProps, ...appProps }) => {
const router = useRouter();

// useEffect(() => {
// const storedLang = localStorage.getItem("lang");
// console.log(router.locale);
// console.log(storedLang);
// if (router.locale ?? "en" !== storedLang ?? "en") {
// router.push(router.pathname, router.pathname, {
// locale: storedLang ?? "en",
// });
// }
// }, [router.locale, router.pathname]);
useEffect(() => {
const storedLang = localStorage.getItem("lang");
if (router.locale ?? "en" !== storedLang ?? "en") {
router.push(router.pathname, router.pathname, {
locale: storedLang ?? "en",
});
}
}, [router.locale, router.pathname]);

useEffect(() => {
// Init for auto capturing
Expand Down

0 comments on commit cfea0dc

Please sign in to comment.