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: allow to destructure props #3382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geovie
Copy link
Contributor

@geovie geovie commented Dec 18, 2024

Allows props to be destructured in the component definition e.g.

    #[prop(name = "data")] UserInfo { email, user_id }: UserInfo,

for that to work a name attribute was introduced which is used to define the name of the prop in the generated builder.

let name = match *typed.pat {
Pat::Ident(i) => {
if let Some(name) = &prop_opts.name {
PatIdent {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also allows to use the new name attribute on props which are not destructured.
That means props can have different names inside the component and outside (builder).

We can also error here if we don't want to allow renaming normal props

@geovie geovie force-pushed the feature/destructured-props branch from f5a2632 to fd6070c Compare December 18, 2024 11:15
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.

1 participant