Skip to content

Commit

Permalink
move initDefaultLanguage to useOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Sep 5, 2024
1 parent 1c35e37 commit fb60838
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/v3/src/components/Widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ export const Widget: FunctionComponent<WidgetProps> = (widgetProps) => {
};
}, [brandColors, customTheme, languageDirection]);

useEffect(() => {
// load default language once
useOnce(() => {
// Load default language.
// Should be called before initial render
initDefaultLanguage();
});

// on unmount, remove the language
return () => {
if (Bundles.isLoaded(languageCode)) {
Bundles.remove();
unloadLanguage(languageCode);
}
};
useEffect(() => () => {
if (Bundles.isLoaded(languageCode)) {
Bundles.remove();
unloadLanguage(languageCode);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit fb60838

Please sign in to comment.