Subscribe on changes!

bind to props by name as svelte

avatar
Apr 28th 2023

What problem does this feature solve?

when passing data to component as prop if it with same name as prop name it will be more prettiy if make short syntax as the following

<Component  :data />

instead of

<Component :data="data"/>

What does the proposed API look like?

when passed data name same as the prop name why we repeat the same word?

avatar
May 5th 2023

You can use v-bind

<Component  v-bind="{ data }" />
avatar
May 6th 2023

We need an RFC for this proposal. Please create a discussion on https://github.com/vuejs/rfcs/discussions

avatar
May 8th 2023

It has already been discussed before in this PR. See Evan's comment on it. 👀

I do like the idea, and a lot of the community has proposed the same idea over the years at least 10 times (See the PR for references). Let's hope this feature lands someday in the future, even if it's only available as an opt-in feature.

By the time being you can do this v-bind shorthand:

Vue Playground Example

<Comp :="{ name }" />

But it's not the same nor as simple as it would be with the proposed syntax:

<Comp :name />
<!-- OR -->
<Comp ::name />
avatar
May 8th 2023

Personally think bad! Because:

<Comp name  />