Replies: 4 comments
-
I like the v-bind option. Also, we can define in the EventCard an interface or similar to define what to receive. |
Beta Was this translation helpful? Give feedback.
-
I would not convert the fact that there are differences in the way you use Passing the properties one by one makes it explicit what's the data needed by the component and minifies unexpected side effects from passing more properties than those needed or reduces the need of creating adaptors in the process. It also avoids creating new objects when the properties come separated. It also helps code tools like Vetur to check those properties. Passing the properties one by one also mimics and honour HTML declarative style and keep data that is relevant to the component close to it. By using For me, it is all about intention and so, I don't see a compulsory conflict in having both of them. |
Beta Was this translation helpful? Give feedback.
-
I agree with the points made by @delapuente. I also think that it makes it easier to read the component's I think this increases the risk of just ignoring what is being passed and may cause unintended side effects. The DX advantages provided by coding tools like Vetur are also a big plus for me. Personally, I would prefer passing all props via A valid scenario I can imagine would be having a stateless wrapper component that really just needs to pass all props to its child component. In this case, defining all props twice may cause even more maintainability issues, due to the props needing to be updated twice. So, |
Beta Was this translation helpful? Give feedback.
-
I find this also to be a very interesting point of view about this pattern:
https://zhenyong.github.io/react/docs/transferring-props.html#manual-transfer In a similar way, I'd prefer to |
Beta Was this translation helpful? Give feedback.
-
When passing dynamic props to a child, we are doing two things:
Note that the first option is the shorthand for:
We should decide which option to use in order to have a consistent code. For me, using
v-bind
results in a cleaner code, so I prefer this option. What do you think?Beta Was this translation helpful? Give feedback.
All reactions