key

Function key 

Source
pub fn key<K, F, R>(key: K, block: F) -> R
where K: Hash, F: FnOnce() -> R,
Expand description

Groups the execution of a block of code with a stable key.

This is useful for maintaining state identity in dynamic lists or loops where the order of items might change.

ยงExamples

use tessera_ui::{key, remember, tessera};

#[tessera]
fn my_list(items: Vec<String>) {
    for item in items.iter() {
        key(item.clone(), || {
            let state = remember(|| 0);
        });
    }
}