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
+25
View File
@@ -0,0 +1,25 @@
import { useState } from "preact/hooks";
import { ComponentChildren } from "preact";
interface PassthroughProps {
children: ComponentChildren;
n: number;
}
export default function Passthrough({ children, n }: PassthroughProps) {
const [v, set] = useState(0);
return (
<div
class="pass-through"
style="background: #85efac; padding: 1rem; border: 4px solid blue; border-radius: .5rem; margin: 1rem;"
>
<h2>This is an Island #{n}</h2>
<button
onClick={() => set((v2) => v2 + 1)}
>
update {v}
</button>
<div style="padding: 1rem 0">{children}</div>
</div>
);
}