UNPKG

react-native-animated-border

Version:
42 lines (37 loc) 856 B
import React from "react"; import { Animated, StyleSheet, Text, View } from "react-native"; import { useAnimation } from "./components/hooks"; export default function RNAnimatedBorder(props) { const { firstColor, secondColor, borderWidth, borderRadius, elevation, margin, padding, } = props; const anim = useAnimation(); const boxInterpolation = anim.interpolate({ inputRange: [0, 1], outputRange: [firstColor, secondColor], }); const animatedStyle = { borderColor: boxInterpolation, }; return ( <Animated.View style={{ ...animatedStyle, borderWidth, borderRadius, elevation, margin, padding, }} > {props.children} </Animated.View> ); } const styles = StyleSheet.create({});