Skip to content

Component with Generic Type that has Generics Itself #3373

Answered by gbj
fabianboesiger asked this question in Q&A
Discussion options

You must be logged in to vote

You are correct that this does not parse in the view macro, and it is a limitation of the rstml crate we use for parsing the view macro.

There are definitely ways to support it; whether you like them or not are another question.

  1. A type alias
  2. Using a function, rather than a component, and calling it as a function (anywhere you can call a function, or in braces in the view)
#[component]
pub fn App() -> impl IntoView {
  view! {
    <p>"Some other content"</p>
    {Component::<Vec<String>>()}
  }
}

fn Component<T>() -> impl IntoView {}
  1. Using a phantom type. Unless I'm mistaken, you can't have a generic component without using the prop anyway, for example as a PhantomData marker, so you c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fabianboesiger
Comment options

Answer selected by fabianboesiger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants