I want to create a treeview component in vue with animations. My idea was to create the treeview recursively without any animations first and then add the TransitionsGroup tag around it.
So you pass a node and its childrens (an array of nodes and its childrens again) to the tree component and it creates the tree. The resulting tree is correct and its HTML will look as follows:
<div v-if.. :key="..">
Root1
</div>
<div v-if.. :key="..">
Child1.1
</div>
<div v-if.. :key="..">
Child2.1
</div>
<div v-if.. :key="..">
Child2.2
</div>
<div v-if.. :key="..">
Child1.2
</div>
But if I add this component inside a TransitionGroup like this
<TransitionGroup tag="div" name="fade">
<Tree :treeData="... />
</TransitionGroup>
I will get warning because the childrens of TransitionGroup must be keyed. So I provided one. But this will result in the following message:
Component inside <Transition> renders non-element root node that cannot be animated.
How can you make this work? I will also appreciate any other ideas which solves this problem.
I also created the example in Vue SFC Playground here: Vue SFC Playground (Comp1 is the tree component and in App.vue line 64 is the problem).