Using template refs makes root component rerender
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
- Open the devtools to see the log
- Click the "Edit Example" button
- See that you have two times the log message for "Rerender App"
What is expected?
The root app is rerendered once
What is actually happening?
The root app is rerenderd twice
System Info
System:
OS: macOS 13.4
CPU: (10) arm64 Apple M1 Pro
Memory: 332.44 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.2 - /opt/homebrew/bin/npm
pnpm: 8.3.1 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 114.0.5735.198
Safari: 16.5
Any additional comments?
When you edit Comp2.vue
and remove the template ref, the rerender of the root-app does not happen anymore.
The second function ( console.log("Rerender App");
) execution is because unmount
was executed during patch
.
u can set a unique key to avoid it .