Lesson 4 of 9
Layout Animations - Entering & Exiting
Reanimated 3's Layout Animations automatically animate components as they enter or exit the render tree. This is the easiest way to add polished list animations, toast notifications, and modal transitions without writing animation code.
Entering & Exiting Presets
import Animated, {
FadeIn, FadeOut,
SlideInRight, SlideOutRight,
SlideInUp, SlideOutDown,
BounceIn, BounceOut,
ZoomIn, ZoomOut,
Layout,
LinearTransition,
} from 'react-native-reanimated';
// ---- List item entrance ----
function TodoItem({ todo, onDelete }: { todo: { id: string; text: string }; onDelete: () => void }) {
return (
<Animated.View
entering={SlideInRight.springify().damping(15)} // spring physics on enter
exiting={SlideOutRight} // slide right on exit
layout={LinearTransition.springify()} // animate remaining items when one is removed
>
<View style={{ backgroundColor: '#1e293b', padding: 16, borderRadius: 10, marginBottom: 8, flexDirection: 'row', alignItems: 'center' }}>
<Text style={{ flex: 1, color: '#f1f5f9' }}>{todo.text}</Text>
<Pressable onPress={onDelete}><Text>โ</Text></Pressable>
</View>
</Animated.View>
);
}
// ---- Toast notification ----
function Toast({ message, visible }: { message: string; visible: boolean }) {
if (!visible) return null;
return (
<Animated.View
entering={SlideInUp.springify()}
exiting={SlideOutDown}
style={{ position: 'absolute', bottom: 84, left: 20, right: 20, backgroundColor: '#1e293b', padding: 14, borderRadius: 12, flexDirection: 'row', alignItems: 'center', gap: 10 }}
>
<Text style={{ fontSize: 18 }}>โ</Text>
<Text style={{ color: '#f1f5f9', flex: 1, fontWeight: '600' }}>{message}</Text>
</Animated.View>
);
}
// ---- Conditional component ----
function ConditionalBadge({ show }: { show: boolean }) {
return show ? (
<Animated.View entering={BounceIn} exiting={ZoomOut}>
<Text style={{ color: '#4ade80', fontWeight: '700' }}>NEW</Text>
</Animated.View>
) : null;
}Tip
Tip
Practice Layout Animations Entering Exiting in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Automatic mount, unmount, and sibling layout re-arrangement transitions
Practice Task
Note
Practice Task - (1) Write a working example of Layout Animations Entering Exiting from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Layout Animations Entering Exiting is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react native code.
Finished this lesson?