sycamore::prelude

Trait Props

pub trait Props {
    type Builder;

    // Required method
    fn builder() -> Self::Builder;
}
Expand description

A trait that is implemented automatically by the Props derive macro.

This is used when constructing components in the view! macro.

§Example

Deriving an implementation and using the builder to construct an instance of the struct:

#[derive(Props)]
struct ButtonProps {
    color: String,
    disabled: bool,
}

let builder = <ButtonProps as Props>::builder();
let button_props = builder.color("red".to_string()).disabled(false).build();

Required Associated Types§

type Builder

The type of the builder. This allows getting the builder type when the name is unknown (e.g. in a macro).

Required Methods§

fn builder() -> Self::Builder

Returns the builder for the type. The builder should be automatically generated using the Props derive macro.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Props for ()

Make sure that the Props trait is implemented for () so that components without props can be thought as accepting props of type ().

§

type Builder = UnitBuilder

§

fn builder() -> <() as Props>::Builder

Implementors§

§

impl Props for NoHydrate_Props

§

type Builder = NoHydrate_PropsBuilder<((),)>

§

impl Props for NoSsr_Props

§

type Builder = NoSsr_PropsBuilder<((),)>

§

impl Props for ShowProps

§

type Builder = ShowPropsBuilder<((), ())>

§

impl Props for SuspenseProps

§

type Builder = SuspensePropsBuilder<((), (), ())>

§

impl<'a, T> Props for Portal_Props<'a, T>
where T: Into<View> + Default,

§

type Builder = Portal_PropsBuilder<'a, ((), ()), T>

§

impl<T, K, U, List, F, Key> Props for KeyedProps<T, K, U, List, F, Key>
where List: Into<MaybeDyn<Vec<T>>> + 'static, F: Fn(T) -> U + 'static, Key: Fn(&T) -> K + 'static, T: 'static,

§

type Builder = KeyedPropsBuilder<((), (), (), ()), T, K, U, List, F, Key>

§

impl<T, U, List, F> Props for IndexedProps<T, U, List, F>
where List: Into<MaybeDyn<Vec<T>>> + 'static, F: Fn(T) -> U + 'static, T: 'static,

§

type Builder = IndexedPropsBuilder<((), (), ()), T, U, List, F>