BUG | toRefs
| When nested, the inner and outer layer fields cannot be updated simultaneously.
#4771
Open
7 tasks done
Labels
Describe the bug
TL;DR;
My objective: To nest the v-model structure while maintaining reactivity
First version: Using vue's toRefs
Suppose there is a drawer component. Every time it is opened, a new copy of the data from Pinia is fetched. The second opening will cause toRefs to fail.
Normal working condition:play
Failure scenarios:play
Second version: Using vueuse.toRefs, the modelValue will remain reactive.
e.g.
However, my situation is rather special. I need to restructure. Below is my situation.
So I had to, once again, deconstruct. But this also brought about problems.
Reproduction: play
After repeated debugging, it was found that if
replaceRef: true
(the default value) is used to usevueuse.toRefs
, it will result in twocustomRef.set
operations.However, the problem lies in the second
customRef.set
, which uses the data beforename.value = 123
to construct newObject, thereby overwriting the modification made in the previous line.Version 3: This is a temporary solution
vueuse.toRefs(modelValue, { replaceRef: false })
However, what I'm unsure about is whether
replaceRef: false
might cause any other bugsReproduction
https://play.vuejs.org/#eNqNVdtu2zgQ/ZVZvdgGbClBtnnQ2kG7aRZIsU2LJrsvVdGo0ihhLJEESfkCw//eQ8py3DZpCwQKOTOcOXM73kSvtI4XLUdpNLWFEdqRZdfqs0yKRivjaENFa51qPnA1JuM/y9wV92NS8q1qpeOStlQZ1dAAfgb7d+eq0Z08i+LE33ycLMpkJgslraOiVpJfM2uaEdPsjN5cv7uKdW4sD8PROiPknajWQx6N+levL/559d+/N5+9BR5+3JBOPciUBkIKdz6g7Zhk3vBOcIUjZJ/6947xmflMhnsAw0OnPlQmk4QuK3L3whL+ShiOcWNqLZOq6NYpFMQOG1Vy/X9etxwv/Hd0S0KG3H22tBR1TV+4UA1DzlXFhRMLjjOJKt+IhlXrhsORT36TSULQ61ZrhRiIZfDGUk6lyZdsCE40YEhHXhXTxYLNmhyckHDeUmmWXI7xQvIS5nrtkXrQZe5ybwGZQL9CV96jODmAhIJ04FGWZ0qSSRT1xdFRKM006SYFM4KL40bXuWPciKalWMBHbu0si5Ym15pNFgXVTrmYVMpAORR4OCZRrka+Yh5EFlE65zWUkOJi3bpm3EphEWGdVjWv/tp7I/823Wz8P9pup2HeFpPQkNS7w0v/7yP0n/BqGmawh5IAS8Afbr2YCNOHCmOgNt2gbLd7o6Sz6p9Ok4PMcQ1ocYx3aYeGUo+dOvCQ+MOkFMZPgpIpelK3jQyqvBZ3cuILYyEHDjZB/oAFxBZMMMAuoNvrgA7dCJGjceQsLCpxFz9YJbHRAUEW+cERNZt32ke0WYT0upyyKK9rtXwTZM60PO7lxT0X8yfkDxadSXF4b9iyWWCh9zqXmztGF7364vqKVzjvlehLW8P6J8oPbFELj7Ez+7uVJWAf2AW0l4FfQAw39mKFetg+KQ/UW26DfRZhAX3Ln0v9Ee5J/Gd4h3qiiv3y/owSdxRYcoWtfutHrifBEDaL0Bss896+Y4unifIH7UuoQTNJoYw3+464DmIOB142CEvZ2YAMO/KDs9nO79AbwQZ4fmE0hsow5rVALyrMbF6DibYjz0uXriOzpTLzx2jFoQsdgDxJbCHcnmQGYbpOT0+RHXnnqHeg0MIrPRI9CPJvgxIVjy7OUQFRgc0GvaGSA/818z8o+AcrpnQb8pzNDoPe7qL+iPQwgIdR4IfjiezBhcdHv0mGPYl9UaZkk9KxXhHGXJSkhZw/cqM+0zPPOhqU03UnXLs2bXvy6QqZ0lRI3bqe7uDei0GZyfMUhcnuBm7S5Po7hugU367H4RR2+3jvnLZpkrRSz+9isEpyaPPy+CQ+jo8SIUtexc0DvO33trez96DX8lfeOqsn/B0s6Wf8+PnFRw4n8Yv4+CTafgVmru2y
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: