From 1fd81d1105f0a527ce223e80c02323ab2bf442c8 Mon Sep 17 00:00:00 2001 From: Vladi Date: Mon, 23 Jun 2025 18:31:14 +0200 Subject: [PATCH] Documented `` component --- src/view/04_iteration.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/view/04_iteration.md b/src/view/04_iteration.md index 7fd241d..2517583 100644 --- a/src/view/04_iteration.md +++ b/src/view/04_iteration.md @@ -297,3 +297,30 @@ fn main() { + +### Accessing an index while iterating with `` + +For the cases where you need to access the real-time index while iterating, +Leptos provides a `` component. + +The props are identical to the `` component, but when rendering `children` +it additionally provides a `ReadSignal` parameter as the index: + +```rust +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +struct Counter { + id: usize, + count: RwSignal +} + + + key=|counter| counter.id // Same as + // Provides the index as a signal and the child T + children={move |index: ReadSignal, counter: Counter| { + view! { + + } + }} +/> +```