forked from baron/baron-sso
네이버 계정 정합성 맞춤
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Fragment, type ReactNode, useEffect, useState } from "react";
|
||||
import { LOCALE_STORAGE_KEY } from "../../../../common/core/i18n";
|
||||
|
||||
type LocaleRefreshBoundaryProps = {
|
||||
children: ReactNode;
|
||||
@@ -12,12 +13,19 @@ function LocaleRefreshBoundary({ children }: LocaleRefreshBoundaryProps) {
|
||||
setLocaleVersion((current) => current + 1);
|
||||
};
|
||||
|
||||
const syncLocaleFromStorage = (event: StorageEvent) => {
|
||||
if (event.key !== LOCALE_STORAGE_KEY && event.key !== null) {
|
||||
return;
|
||||
}
|
||||
syncLocale();
|
||||
};
|
||||
|
||||
window.addEventListener("localechange", syncLocale);
|
||||
window.addEventListener("storage", syncLocale);
|
||||
window.addEventListener("storage", syncLocaleFromStorage);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("localechange", syncLocale);
|
||||
window.removeEventListener("storage", syncLocale);
|
||||
window.removeEventListener("storage", syncLocaleFromStorage);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user