Struct leptos::ProviderProps
source · pub struct ProviderProps<T>where
T: Clone + 'static,{
pub value: T,
pub children: Children,
}
Expand description
Props for the Provider
component.
Uses the context API to provide_context
to its children and descendants,
without overwriting any contexts of the same type in its own reactive scope.
This prevents issues related to “context shadowing.”
#[component]
pub fn App() -> impl IntoView {
// each Provider will only provide the value to its children
view! {
<Provider value=1u8>
// correctly gets 1 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
<Provider value=2u8>
// correctly gets 2 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
// does not find any u8 in context
{use_context::<u8>().unwrap_or(0)}
}
}
§Required Props
- value: [
T
]- The value to be provided via context.
- children:
Children
Fields§
§value: T
The value to be provided via context.
children: Children
Implementations§
source§impl<T> ProviderProps<T>where
T: Clone + 'static,
impl<T> ProviderProps<T>where
T: Clone + 'static,
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ProviderProps<T>where
T: Freeze,
impl<T> !RefUnwindSafe for ProviderProps<T>
impl<T> !Send for ProviderProps<T>
impl<T> !Sync for ProviderProps<T>
impl<T> Unpin for ProviderProps<T>where
T: Unpin,
impl<T> !UnwindSafe for ProviderProps<T>
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