feat: allow passing JSX children to island + nested islands (#1285)
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user