Component with Generic Type that has Generics Itself #3373
Answered
by
gbj
fabianboesiger
asked this question in
Q&A
-
Hi All, I'm trying to construct something like this:
It seems that Leptos is unable to parse this. Is there any way to support this? A type alias appears to work, it is however not ideal. |
Beta Was this translation helpful? Give feedback.
Answered by
gbj
Dec 17, 2024
Replies: 1 comment 1 reply
-
You are correct that this does not parse in the There are definitely ways to support it; whether you like them or not are another question.
#[component]
pub fn App() -> impl IntoView {
view! {
<p>"Some other content"</p>
{Component::<Vec<String>>()}
}
}
fn Component<T>() -> impl IntoView {}
#[component]
pub fn App() -> impl IntoView {
view! {
<Component marker={PhantomData::<Vec<String>>}/>
}
}
#[component]
fn Component<T>(#[prop(optional)] marker: PhantomData<T>) -> impl IntoView {}
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
fabianboesiger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are correct that this does not parse in the
view
macro, and it is a limitation of therstml
crate we use for parsing theview
macro.There are definitely ways to support it; whether you like them or not are another question.
PhantomData
marker, so you c…