mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-14 04:28:49 +00:00
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:
@@ -106,16 +106,6 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
|||||||
const redirectFn = useRef<(() => void) | null>(null);
|
const redirectFn = useRef<(() => void) | null>(null);
|
||||||
const detailsRead = useRef(false);
|
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
|
// Main initialization
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const details = document.querySelector("details");
|
const details = document.querySelector("details");
|
||||||
@@ -132,6 +122,12 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
|||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
setErrorImage(imageSrc);
|
setErrorImage(imageSrc);
|
||||||
setPhase("error");
|
setPhase("error");
|
||||||
|
|
||||||
|
// sync title element (it's outside of the JSX tree)
|
||||||
|
const titleEl = document.getElementById("title");
|
||||||
|
if (titleEl) {
|
||||||
|
titleEl.textContent = title;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dependencies = [
|
const dependencies = [
|
||||||
|
|||||||
Reference in New Issue
Block a user