A first example
A first example in the Control flow in depth guide.
src/profile.tsxtsx
import { useStore } from "@shadow-js/core";
import { For, Show } from "@shadow-js/web";
export function Profile() {
const [user] = useStore<{ name: string; tags: string[] }>({ name: "Ada", tags: ["dev", "ops"] });
return (
<Show when={user.name} fallback={<p>Anonymous</p>}>
<p>
{user.name}, {user.tags.length} tags:{" "}
<For each={user.tags}>{(tag, index) => <span>{index() > 0 ? ", " : ""}{tag}</span>}</For>
</p>
</Show>
);
}