VuReact is a compiler toolchain for migrating from Vue to React — and for writing React with Vue 3 syntax.
In this article, we will look at how Vue's built-in <TransitionGroup> component is compiled into React code.
Before We Start
To keep the examples easy to read, this article follows two simple conventions:
- All Vue and React snippets focus on core logic only, with full component wrappers and unrelated configuration omitted.
- The discussion assumes you are already familiar with Vue 3
<TransitionGroup>.
Compilation Mapping
List transition animations
<TransitionGroup> is Vue's built-in component for entering, leaving, and moving list items. It is the list-oriented counterpart to <Transition>.
- Vue
<template>
<TransitionGroup name="list" tag="ul">
<li v-for="item in items" :key="item.id">
{{ item.name }}
</li>
</TransitionGroup>
</template>
- Compiled React
import { TransitionGroup } from '@vureact/runtime-core';
<TransitionGroup name="list" tag="ul">
{items.map((item) => (
<li key={item.id}>{item.name}</li>
))}
</TransitionGroup>;
As the example shows, Vue <TransitionGroup> is compiled into the VuReact Runtime TransitionGroup adapter.
This mapping preserves the core behavior of list transitions:
- It keeps the Vue-style transition semantics intact.
- It supports entering, leaving, and moving items in a list.
- It respects the
tagprop for container rendering. - It still requires stable
keyvalues for each list item.
Move transitions
<TransitionGroup> also supports smooth move animations when list items are reordered, usually through the move-class prop.
- Vue
<template>
<TransitionGroup name="list" tag="ul" move-class="list-move">
<li v-for="item in items" :key="item.id">
{{ item.name }}
</li>
</TransitionGroup>
</template>
- Compiled React
<TransitionGroup name="list" tag="ul" moveClass="list-move">
{items.map((item) => (
<li key={item.id}>{item.name}</li>
))}
</TransitionGroup>;
.list-move {
transition: all 0.5s ease;
}
.list-leave-active {
position: absolute;
}
Under the hood, move transitions are typically implemented with FLIP-style positioning and CSS transform transitions, which makes reordering feel smooth without sacrificing performance.
Custom container elements
The tag prop controls the rendered container element type.
- Vue
<template>
<TransitionGroup name="fade" tag="div" class="item-list">
<div v-for="item in items" :key="item.id" class="item">
{{ item.name }}
</div>
</TransitionGroup>
</template>
- Compiled React
<TransitionGroup name="fade" tag="div" className="item-list">
{items.map((item) => (
<div key={item.id} className="item">
{item.name}
</div>
))}
</TransitionGroup>;
The tag prop keeps the generated DOM structure explicit and easy to reason about.
Transition features are preserved
<TransitionGroup> inherits the same transition-related capabilities as <Transition>, including classes and hooks.
- Vue
<template>
<TransitionGroup
name="slide"
tag="div"
:duration="500"
@enter="onEnter"
@leave="onLeave"
>
<div v-for="item in items" :key="item.id">
{{ item.name }}
</div>
</TransitionGroup>
</template>
- Compiled React
<TransitionGroup
name="slide"
tag="div"
duration={500}
onEnter={onEnter}
onLeave={onLeave}
>
{items.map((item) => (
<div key={item.id}>{item.name}</div>
))}
</TransitionGroup>;
VuReact preserves the transition API surface so list animations remain familiar after migration.
Compilation Summary
VuReact's TransitionGroup compilation strategy shows a complete list transition migration path:
- Vue
<TransitionGroup>is mapped directly to the runtime adapter. - Core props such as
name,tag, andmoveClassare supported. -
v-forrendering becomesmap()rendering in React. - Transition hooks and animation behavior are preserved.
The result is a React implementation that keeps Vue's list transition semantics while fitting into React's component model.
Top comments (0)