Function Suspense
pub fn Suspense(props: SuspenseProps) -> View
Expand description
Suspense
lets you wait for async
tasks to complete before rendering the UI. This is useful
for asynchronous data-fetching or other asynchronous tasks.
Suspense
is deeply integrated with async components.
Async components that are nested under the Suspense
component will not be rendered until they
are resolved. Having multiple async components will have the effect that the final UI will only
be rendered once all individual async components are rendered. This is useful for showing a
loading indicator while the data is being loaded.
ยงExample
use sycamore::prelude::*;
use sycamore::web::Suspense;
#[component]
async fn AsyncComp() -> View {
view! { "Hello Suspense!" }
}
#[component]
fn App() -> View {
view! {
Suspense(fallback=|| view! { "Loading..." }) {
AsyncComp {}
}
}
}