Flash animation — flashing effect.
Implementation:
1import { Animated } from "react-native";23function FlashView({ children }) {4 const flashAnim = useRef(new Animated.Value(1)).current;56 useEffect(() => {7 Animated.loop(8 Animated.sequence([9 Animated.timing(flashAnim, {10 toValue: 0,11 duration: 200,12 useNativeDriver: true,13 }),14 Animated.timing(flashAnim, {15 toValue: 1,16 duration: 200,17 useNativeDriver: true,18 }),19 ]),20 { iterations: 3 }21 ).start();22 }, []);2324 return (25 <Animated.View style={{ opacity: flashAnim }}>26 {children}27 </Animated.View>28 );29}