The Transition does not take effect when using conditional judgment on the diff element in the render function.
Vue version
3.3.8
Link to minimal reproduction
https://github.com/vuejs/core/assets/41265413/a69ed32a-d955-4316-be6e-f472bbcc5992
Steps to reproduce
- click toggle button
- The one above didn't work. The one below, written with sfc, works.
What is expected?
- all should works
What is actually happening?
- component written in render function not working
System Info
No response
Any additional comments?
No response
This is equivalent to implementing the runtime code generated by the compiler yourself, so you need to add key
In the above example, I used the h
function without adding a key, which caused a problem. I understand that a key needs to be added during the compilation process. So it is reasonable to add a key manually here.
However, if written in tsx , tsx should go through compilation and still not work.
<Transition
name="rotate"
>
{!isDark.value ? (
<i
class={'inline-block h-5 w-5 i-mingcute-sun-line'}
/>
) : (
<i
class={'inline-block h-5 w-5 i-mingcute-moon-line'}
/>
)}
</Transition>