I'm really sick of not making any progress

This commit is contained in:
2024-03-12 04:53:54 -06:00
parent ed4497b991
commit 3c8f5bb8ba
16 changed files with 863 additions and 167 deletions

View File

@@ -1,3 +1,5 @@
"use client";
import { FC, PropsWithChildren, useEffect, useState } from "react";
import { createPortal } from "react-dom";
@@ -12,9 +14,10 @@ export const Portal: FC<PropsWithChildren<IProps>> = (
const [container] = useState(() => {
// This will be executed only on the initial render
// https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
return document.getElementById("root-portal")!;
return document.getElementById("root-portal") || document.createElement(el);
});
// todo: this smells. appending the same element?
useEffect(() => {
container.classList.add(className);
document.body.appendChild(container);