diff --git a/packages/core/src/Controller/Controller.ts b/packages/core/src/Controller/Controller.ts index 640d6c6c47..8f23c98e4c 100644 --- a/packages/core/src/Controller/Controller.ts +++ b/packages/core/src/Controller/Controller.ts @@ -63,6 +63,8 @@ export function Controller({ options }: StateServiceProps) { init(options); } + let runPromise: Promise | undefined; + events.onUpdate.listen(() => { if (state.isRunning()) { pluginService.retranslate(); @@ -283,14 +285,13 @@ export function Controller({ options }: StateServiceProps) { }, run() { - let result: Promise | undefined = undefined; checkCorrectConfiguration(); if (!state.isRunning()) { state.setRunning(true); pluginService.run(); - result = loadInitial(); + runPromise = loadInitial(); } - return Promise.resolve(result); + return Promise.resolve(runPromise); }, stop() { diff --git a/packages/react/src/useTranslateInternal.ts b/packages/react/src/useTranslateInternal.ts index 3c7433844c..a3070beb61 100644 --- a/packages/react/src/useTranslateInternal.ts +++ b/packages/react/src/useTranslateInternal.ts @@ -42,9 +42,7 @@ export const useTranslateInternal = ( useEffect(() => { const subscription = tolgee.onNsUpdate(rerender); subscriptionRef.current = subscription; - if (!isLoaded) { - subscription.subscribeNs(namespaces); - } + subscription.subscribeNs(namespaces); subscriptionQueue.current.forEach((ns) => { subscription!.subscribeNs(ns); }); @@ -52,7 +50,7 @@ export const useTranslateInternal = ( return () => { subscription.unsubscribe(); }; - }, [isLoaded, namespacesJoined, tolgee]); + }, [namespacesJoined, tolgee]); useEffect(() => { tolgee.addActiveNs(namespaces);