Skip to content

[Question]: Why is there a default prop for every controlled component? #763

Closed Answered by zernonia
Saeid-Za asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the question @Saeid-Za !

  1. Because in certain case we want a uncontrolled version of the component. Let's say I want to have default AccordionItem to be opened, thus we set defaultValue: 'accordion-2'. We can't use modelValue: 'accordion-2' because it would cause the Accordion internal state not to be updated. We can't also use v-model="accordion-2" (static value) as well.

  2. We don't use defineModel as we wanna support 3.3 version. Also, using useVModel allow us to forward props and emits easily. We dont need to export another defineModel's types 1-by-1.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Saeid-Za
Comment options

You must be logged in to vote
2 replies
@zernonia
Comment options

@Saeid-Za
Comment options

Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #760 on March 18, 2024 08:59.