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

Set value to defineModel twice in child component not working as intended #10990

Closed
dinyo opened this issue May 22, 2024 · 3 comments
Closed

Comments

@dinyo
Copy link

dinyo commented May 22, 2024

Vue version

3.4.27

Link to minimal reproduction

https://play.vuejs.org/#eNp9Uslq40AQ/ZWmL3GIRzYzAwMe2cxCDjOQhSTHhiBLZUdJq7vpRTEI/XuqWpEskeUgJNV7r9bX8N/GJHUAvuKpy21pPHPgg9kIK1RZGW09a5iFHWvZzuqKnSD55OcI/asr8wolC/qhdB2Dnlwr55mqtpatKc9seRqxdNGVi4ViwENlZOYhRhhLY+L6S6ULkGvBKYXgmzTWiJx0MUj4nHuHpXblPnl0WuE4DSURPEd2KcFeGV9iK4KvWEQIy6TUz/9jzNsA8z6eP0D+9E780R0oJvi1BQe2BsEHzGd2D76Dz28v4YDfA4gzBInsT8AbcFoG6rGj/QmqwLZHvNjtv7j0Uu3v3PnBg3L9UNQoMdvIFxyPQIv6aPRju9+S71EnVItb7A/41g8TN8zZc+bzh4kp8Iz9tUO1Bbp3AbtSwQVdcNbgTxakX7FlixaYUG/QX0d3DHmyorjsU81O2XrT9d9pkjqTARBZomIaPDuLSfogZn+XPMQjHxdw9CSqR34kNzqTqU2nwzU2/YxtiyKCImlrp++RCIuNdDTwID3KgvdasV+5LPMntPwwP/oev9NFR0DyyPpC4dnua7BkBTwb3jP5+oO3LzmTTbg=

Steps to reproduce

click the add button.

What is expected?

number value should the same as numberRef value.

What is actually happening?

when i set defineModel value to 0, somehow is ignored because there is another setter. and it never set to 0 and the value is incrementing. but if the increment line removed, it is set to 0.

System Info

No response

Any additional comments?

is there racing condition between parent and child when sync? should i use emit instead defineModel?

@dinyo
Copy link
Author

dinyo commented May 22, 2024

sorry, i intended to zeroing the value to compare the effect. number is ignoring the 0 and keep adding. numberRef is set to 0 first before adding.

@Shyam-Chen
Copy link
Contributor

Shyam-Chen commented May 22, 2024

  number.value = 0;
- number.value += 1;
+ nextTick(() => {
+   number.value += 1;
+ });

@dinyo
Copy link
Author

dinyo commented May 22, 2024

ah, thanks. i used emit before so i am not aware of this.

@dinyo dinyo closed this as completed May 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants