feat: allow passing JSX children to island + nested islands (#1285)

This commit is contained in:
Marvin Hagemeister
2023-06-15 10:08:48 +02:00
committed by GitHub
parent 372d0dfffb
commit ce0eda7654
24 changed files with 873 additions and 67 deletions
@@ -0,0 +1,9 @@
import { ComponentChildren } from "preact";
export default function Island(props: { children?: ComponentChildren }) {
return (
<div class="island">
{props.children}
</div>
);
}
@@ -0,0 +1,19 @@
import { useEffect, useState } from "preact/hooks";
export default function IslandWithProps(
props: { foo: { bar: string } },
) {
const [showText, setShowText] = useState(false);
useEffect(() => {
setShowText(true);
}, []);
return (
<div class="island">
<p>
{showText ? props.foo.bar : "it doesn't work"}
</p>
</div>
);
}