Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add component generics #1636

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

mrvillage
Copy link
Contributor

Adds support for passing generics straight into components using native support in rstml, should close #1176.

@gbj
Copy link
Collaborator

gbj commented Sep 4, 2023

Awesome! Thanks!

@gbj gbj merged commit 6e00834 into leptos-rs:main Sep 4, 2023
@gbj
Copy link
Collaborator

gbj commented Sep 4, 2023

Note to self re: the syntax, for when I add this to release notes, or for anyone else curious:

#[component]
pub fn GenericComponent<S>(ty: PhantomData<S>) -> impl IntoView {
    std::any::type_name::<S>()
}

#[component]
pub fn App() -> impl IntoView {
    view! {
        <GenericComponent<String> ty=PhantomData />
        <GenericComponent<usize> ty=PhantomData/>
        <GenericComponent<i32> ty=PhantomData/>
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding value require type annotations in some cases.
2 participants