diff --git a/src/App.tsx b/src/App.tsx index d4df1d09..bcd049b1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -72,7 +72,9 @@ export const App: FC = ({ history }) => { const [loaded, setLoaded] = useState(false); useEffect(() => { Initializer.init()?.then(() => { + if (loaded) return; setLoaded(true); + widget?.api.sendContentLoaded(); }); }); diff --git a/src/useTheme.ts b/src/useTheme.ts index 18f1e741..34395ff2 100644 --- a/src/useTheme.ts +++ b/src/useTheme.ts @@ -17,11 +17,9 @@ limitations under the License. import { useLayoutEffect, useRef } from "react"; import { useUrlParams } from "./UrlParams"; -import { widget } from "./widget"; export const useTheme = (): void => { const { theme: themeName } = useUrlParams(); - const contentLoadedSent = useRef(false); const previousTheme = useRef(document.body.classList.item(0)); useLayoutEffect(() => { // If the url does not contain a theme props we default to "dark". @@ -39,9 +37,5 @@ export const useTheme = (): void => { previousTheme.current = themeString; } document.body.classList.remove("nodisplay"); - if (!contentLoadedSent.current) { - widget?.api.sendContentLoaded(); - contentLoadedSent.current = true; - } }, [previousTheme, themeName]); };