-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Resource::loading
causes orphaned elements when used for conditional rendering.
#1457
Comments
This is essentially a hydration mismatch in a section of the view that creates an element depending on a resource without using It's pretty straightforward to understand why it happens:
There are a couple possible solutions here:
|
Thanks! That makes sense. I ended up using this: #[component]
fn WhileLoading<S, T>(cx: Scope, resource: Resource<S, T>, children: ChildrenFn) -> impl IntoView
where
S: Clone + 'static,
T: Clone + 'static,
{
view! { cx,
<Suspense fallback=move || children(cx)>
{move || resource.with(cx, |_| ())}
</Suspense>
}
} which I presume is what you meant with I don't know if you want to deal with it on the leptos side or not so feel free to close if you want to. |
#1586 implements my third suggestion above
I've tested it and this behaves correctly if you use |
Describe the Bug
See title and expected/actual behavior. It seems to work fine when used to conditionally apply a class though.
Leptos Dependencies
To Reproduce
change
HomePage
insrc/app.rs
to:Expected behavior
Loading...
is visible only when the resource is loading.Actual behavior
Loading...
permanently visible in addition to the one that appears when you press the button.component with id _0-16c not found, ignoring it for hydration
is printed in the console.The text was updated successfully, but these errors were encountered: