fix(js/main): move title updating from an effect to the error handler function

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2026-03-20 10:40:43 +00:00
parent 2ac8928ff7
commit b9b7a40923

View File

@@ -106,16 +106,6 @@ function App({ anubisVersion, basePrefix }: AppProps) {
const redirectFn = useRef<(() => void) | null>(null);
const detailsRead = useRef(false);
// Sync <h1 id="title"> when entering error state (it's outside the Preact tree)
useEffect(() => {
if (phase === "error") {
const titleEl = document.getElementById("title");
if (titleEl) {
titleEl.textContent = errorTitle;
}
}
}, [phase, errorTitle]);
// Main initialization
useEffect(() => {
const details = document.querySelector("details");
@@ -132,6 +122,12 @@ function App({ anubisVersion, basePrefix }: AppProps) {
setErrorMessage(message);
setErrorImage(imageSrc);
setPhase("error");
// sync title element (it's outside of the JSX tree)
const titleEl = document.getElementById("title");
if (titleEl) {
titleEl.textContent = title;
}
};
const dependencies = [