feat: support conditional island JSX children (#1355)

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Marvin Hagemeister
2023-08-08 11:35:28 +02:00
committed by GitHub
co-authored by Asher Gomez
parent dff80d3a42
commit 11077227b5
8 changed files with 205 additions and 49 deletions
@@ -0,0 +1,10 @@
import { Signal } from "@preact/signals";
export default function Counter({ count }: { count: Signal<number> }) {
return (
<div>
<p class="count">{count}</p>
<button class="counter" onClick={() => count.value++}>update</button>
</div>
);
}
@@ -1,9 +1,17 @@
import { Signal } from "@preact/signals";
import { ComponentChildren } from "preact";
export interface IslandConditionalProps {
show: Signal<boolean>;
children?: ComponentChildren;
}
export default function IslandConditional({ show }: IslandConditionalProps) {
return show.value ? <>it works</> : null;
export default function IslandConditional(
{ show, children }: IslandConditionalProps,
) {
return (
<div class="island">
{show.value ? <p>island content</p> : <>{children}</>}
</div>
);
}