pub struct ShowProps<W>{
pub children: ChildrenFn,
pub when: W,
pub fallback: ViewFn,
}
Expand description
Props for the Show
component.
A component that will show its children when the when
condition is true
,
and show the fallback when it is false
, without rerendering every time
the condition changes.
The fallback prop is optional and defaults to rendering nothing.
let (value, set_value) = create_signal(0);
view! {
<Show
when=move || value.get() < 5
fallback=|| view! { "Big number!" }
>
"Small number!"
</Show>
}
§Required Props
- children:
ChildrenFn
- The children will be shown whenever the condition in the
when
closure returnstrue
.
- The children will be shown whenever the condition in the
- when: [
W
]- A closure that returns a bool that determines whether this thing runs
§Optional Props
- fallback:
impl Into<ViewFn>
- A closure that returns what gets rendered if the when statement is false. By default this is the empty view.
Fields§
§children: ChildrenFn
The children will be shown whenever the condition in the when
closure returns true
.
when: W
A closure that returns a bool that determines whether this thing runs
fallback: ViewFn
A closure that returns what gets rendered if the when statement is false. By default this is the empty view.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for ShowProps<W>where
W: Freeze,
impl<W> !RefUnwindSafe for ShowProps<W>
impl<W> !Send for ShowProps<W>
impl<W> !Sync for ShowProps<W>
impl<W> Unpin for ShowProps<W>where
W: Unpin,
impl<W> !UnwindSafe for ShowProps<W>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more