-
Hi folks Playing around with leptos and finding the process fun, and relatively painless. Back to my question. Is there a way to reuse original component props? Let's I want to make my own button to make sure consistent style. In TypeScript I would do something like this:
What would be the way to do something like this in Leptos? Also, if there is no direct alternative, how can I declare my own properties while reusing some of those from the HTML native button? For example:
While with Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Coincidentally just merged a PR (#1619) to make it easier to spread attributes onto an element with a By "reuse original component props" I think you mean "reuse typed HTML element attributes," right? We don't have built-in types for attributes. Remember that TypeScript and Rust have very different type systems: ButtonProps in your React example is essentially a HashMap with some type-checking, which means it is always heap-allocated* but only takes up space in memory for fields it actually contains. A Rust struct would be a struct, not a map, but take up space for all fields. Given that HTML is very dynamically typed, the overhead of this makes it less than ideal for our framework purposes. So there are no built-in types for things like typical HTML attributes for a given element.
|
Beta Was this translation helpful? Give feedback.
Coincidentally just merged a PR (#1619) to make it easier to spread attributes onto an element with a
{..attributes}
syntax.By "reuse original component props" I think you mean "reuse typed HTML element attributes," right? We don't have built-in types for attributes. Remember that TypeScript and Rust have very different type systems: ButtonProps in your React example is essentially a HashMap with some type-checking, which means it is always heap-allocated* but only takes up space in memory for fields it actually contains. A Rust struct would be a struct, not a map, but take up space for all fields. Given that HTML is very dynamically typed, the overhead of this makes it less than ideal f…