use crate::context::use_clerk_context;
use dioxus::prelude::*;
#[component]
pub fn SignedOut(
#[props(default = true)]
treat_pending_as_signed_out: bool,
children: Element,
) -> Element {
let ctx = use_clerk_context();
let auth = ctx.auth.read();
if auth
.resolve_pending(treat_pending_as_signed_out)
.should_render_signed_out()
{
rsx! { {children} }
} else {
rsx! {}
}
}
#[component]
pub fn SignedOutWhenLoaded(
#[props(default = rsx! {})]
fallback: Element,
#[props(default = true)]
treat_pending_as_signed_out: bool,
children: Element,
) -> Element {
let ctx = use_clerk_context();
let auth = ctx.auth.read();
let auth = auth.resolve_pending(treat_pending_as_signed_out);
let load_error = ctx.load_error.read();
if auth.is_loaded() && auth.should_render_signed_out() {
rsx! { {children} }
} else if !auth.is_loaded() && !auth.is_signed_in() && load_error.is_none() {
fallback
} else {
rsx! {}
}
}