feat: add SuspenseWrapper component for SSR
This commit is contained in:
parent
5e449013d6
commit
60a2cd49ab
@ -6,4 +6,5 @@ pub mod nav;
|
|||||||
pub mod page_layout;
|
pub mod page_layout;
|
||||||
pub mod post;
|
pub mod post;
|
||||||
pub mod post_card;
|
pub mod post_card;
|
||||||
|
pub mod suspense_wrapper;
|
||||||
pub mod write_skeleton;
|
pub mod write_skeleton;
|
||||||
|
|||||||
21
src/components/suspense_wrapper.rs
Normal file
21
src/components/suspense_wrapper.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
|
/// Wraps children in a SuspenseBoundary with a loading skeleton fallback.
|
||||||
|
/// Used for pages that fetch data via `use_server_future`.
|
||||||
|
#[component]
|
||||||
|
pub fn SuspenseWrapper(children: Element) -> Element {
|
||||||
|
rsx! {
|
||||||
|
SuspenseBoundary {
|
||||||
|
fallback: |_| rsx! {
|
||||||
|
div { class: "animate-pulse py-6 space-y-4",
|
||||||
|
div { class: "h-10 w-3/4 bg-paper-tertiary rounded" }
|
||||||
|
div { class: "h-4 w-32 bg-paper-tertiary rounded" }
|
||||||
|
div { class: "h-4 w-full bg-paper-tertiary rounded mt-8" }
|
||||||
|
div { class: "h-4 w-full bg-paper-tertiary rounded" }
|
||||||
|
div { class: "h-4 w-2/3 bg-paper-tertiary rounded" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{children}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user