MyGit

v0.6.12

leptos-rs/leptos

版本发布时间: 2024-06-03 02:27:13

leptos-rs/leptos最新发布版本:v0.7.0-rc0(2024-10-22 09:30:46)

This is mainly a maintenance release, but includes a couple new features that I want to point out:

impl Trait in Component Props

You can now use impl Trait syntax directly in component props, rather than explicitly specifying a generic and a where clause

before

#[component]
fn ProgressBar<F>(#[prop(default = 100)] max: u16, progress: F) -> impl IntoView
where
    F: Fn() -> i32 + 'static,
{
    view! {
        <progress
            max=max
            value=progress
        />
    }
}

after

#[component]
fn ProgressBar(
    #[prop(default = 100)] max: u16,
    progress: impl Fn() -> i32 + 'static,
) -> impl IntoView {
    view! {
        <progress
            max=max
            value=progress
        />
    }
}

Support spreading dynamic attributes from one component to another

In the following code Bar doesn't currently inherit attributes from Foo when it spreads its attributes. PR #2534 fixes this.

fn main() {
    let (count, set_count) = create_signal(0);

    mount_to_body(move || {
        view! {
            <Foo
                attr:hello=move || count.get().to_string()
            />

            <button on:click=move|_| { set_count.update(|count| *count += 1) }>"+ count"</button>
        }
    });
}

#[component]
fn Foo(#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>) -> impl IntoView {
    view! {
        <Bar {..attrs} />
    }
}

#[component]
fn Bar(#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>) -> impl IntoView {
    view! {
        <div {..attrs}>"hello world"</div>
    }
}

Complete Changelog

New Contributors

Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.6.11...v0.6.12

相关地址:原始地址 下载(tar) 下载(zip)

查看:2024-06-03发行的版本