Skip to content

Is there a way to use HTML component props for own components? #1643

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

You must be logged in to vote

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…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by Umenokin
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