You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
would result in MyCounter preserving its internal state when option changes. It would receive updated prop as expected, however internal data/ref state inside of the component would not change, and when option changes there would be no unmounting and mounting.
The core issue stems from not having a key like <MyCounter key="1" myprop="1" />. We have inspected the compiled JavaScript code of vanilla Vue 3 using v-if with the compiled code of the latest Vue JSX app and the core difference was that vanilla Vue was adding key=0 and key=1 automatically, while the JSX plugin was not.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Related plugins
plugin-vue
plugin-vue-jsx
Describe the bug
My colleague @tongxuanbao and I found an interesting issue when using JSX in Vue 3 for conditional rendering.
The symptom was that having this code:
would result in
MyCounter
preserving its internal state whenoption
changes. It would receive updated prop as expected, however internal data/ref state inside of the component would not change, and whenoption
changes there would be no unmounting and mounting.The core issue stems from not having a key like
<MyCounter key="1" myprop="1" />
. We have inspected the compiled JavaScript code of vanilla Vue 3 usingv-if
with the compiled code of the latest Vue JSX app and the core difference was that vanilla Vue was addingkey=0
andkey=1
automatically, while the JSX plugin was not.Here's the compiled vanilla Vue code:
And here's the compiled JSX code:
Reproduction
https://stackblitz.com/edit/vitejs-vite-ygezuc?file=src%2FApp.jsx
Steps to reproduce
npm install && npm run dev
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: