Add Partials (#1824)

This commit is contained in:
Marvin Hagemeister
2023-09-27 13:34:30 +02:00
committed by GitHub
parent d9829e25e6
commit 665d35bbc2
92 changed files with 3271 additions and 116 deletions
+30
View File
@@ -0,0 +1,30 @@
import { ComponentChildren } from "preact";
import { useEffect, useRef } from "preact/hooks";
export function Logger(props: { children?: ComponentChildren; name?: string }) {
const mounted = useRef(false);
useEffect(() => {
mounted.current = true;
const logs = document.querySelector("#logs");
if (logs) {
logs.textContent += `mount ${props.name}\n`;
}
return () => {
if (logs) {
logs.textContent += `unmount ${props.name}\n`;
}
};
}, []);
if (mounted.current && typeof document !== "undefined") {
const logs = document.querySelector("#logs");
if (logs) {
logs.textContent += `update ${props.name}\n`;
}
}
// deno-lint-ignore no-explicit-any
return props.children as any;
}