Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<For/> blocks do not update when For.each is cleared (Vec::clear) if there is a sibling after it. #1076

Closed
Vonr opened this issue May 22, 2023 · 0 comments

Comments

@Vonr
Copy link

Vonr commented May 22, 2023

use leptos::*;

fn main() {
    mount_to_body(|cx| {
        let (list, set_list) = create_signal(cx, (0..100).collect());

        view! { cx,
            <button on:click=move |_| set_list.update(Vec::clear)>"Clear"</button>
            <Test list=list />
        }
    });
}

#[component]
fn Test(cx: Scope, list: ReadSignal<Vec<usize>>) -> impl IntoView {
    view! { cx,
        <div>
            <For each=list key=|&e| e view=move |cx, e| view! { cx,
                <p>{e}</p>
            }/>
            <h1>Footer</h1> // Removing this resolves the issue
        </div>
    }
}

CodeSandbox:
https://codesandbox.io/p/sandbox/table-weirdness-forked-43k8py?selection=%5B%7B%22endColumn%22%3A6%2C%22endLineNumber%22%3A55%2C%22startColumn%22%3A5%2C%22startLineNumber%22%3A31%7D%5D&file=%2FCargo.toml%3A7%2C17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants