maciejhirsz / kobold

Easy declarative web interfaces.
https://docs.rs/kobold/
Mozilla Public License 2.0
385 stars 7 forks source link

`invar`: the unconditional `fence` #98

Closed maciejhirsz closed 2 months ago

maciejhirsz commented 2 months ago

I found that I have some place that use params but always produce static DOM, so a way to make an entire component static rather than just few strings with the static keyword is useful.

Before 0.10 is released this might be worth putting into the #[component] macro as #[component(static)].

use kobold::prelude::*;
use kobold::diff::invar;

#[component]
fn tag(label: &'static str) -> impl View {
    invar(move || view! {
        <span.tag>{ static label }</span>
    })
}