$ git show word-rotate
Rotating word
One word in a headline cycles through options, each sliding up and out as the next slides in.
Build
// Unchanged in Reanimated 4: entering/exiting layout animations still drive mount and unmount
import Animated, { FadeInUp, FadeOutUp } from 'react-native-reanimated';
const WORDS = ['faster', 'smoother', 'together'];
const [i, setI] = useState(0);
useEffect(() => {
const id = setInterval(() => setI((n) => (n + 1) % WORDS.length), 2000);
return () => clearInterval(id);
}, []);
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Text style={styles.title}>Build </Text>
{/* Fixed height + overflow hidden clips the word as it slides */}
<View style={{ height: 34, overflow: 'hidden' }}>
<Animated.Text
key={i}
entering={FadeInUp.springify().damping(16)}
exiting={FadeOutUp.duration(200)}
style={[styles.title, { color: '#2F54EB' }]}>
{WORDS[i]}
</Animated.Text>
</View>
</View>