From 52cb91ee2735278df6f64decb2ee290d203ea093 Mon Sep 17 00:00:00 2001 From: Kimye <9964078+vinchona@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:17:17 +0100 Subject: [PATCH] docs(island): provide correct Tab fn (#131) Co-authored-by: Arthur Vinchon --- src/islands.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/islands.md b/src/islands.md index fe19f34..8467db0 100644 --- a/src/islands.md +++ b/src/islands.md @@ -354,15 +354,22 @@ And let’s modify the `Tab` island to use that context to show or hide itself: ```rust #[island] -fn Tab(children: Children) -> impl IntoView { +fn Tab(index: usize, children: Children) -> impl IntoView { let selected = expect_context::>(); view! { -
-// ... +
+ {children()} +
+ } +} ``` Now the tabs behave exactly as I’d expect. `Tabs` passes the signal via context to each `Tab`, which uses it to determine whether it should be open or not.