One liner hook to get an Animated.Value from a value.
npm install @brigad/use-animated-value
or
yarn add @brigad/use-animated-value
import useAnimatedValue from "@brigad/use-animated-value";
const BoxWithAnimatedBackgroundColor = ({color}) => {
const animatedColor = useAnimatedValue(color);
return <Animated.View style={{backgroundColor: animatedColor}} />
}
type Options<T> = {
useNativeDriver?: boolean;
duration?: number;
easing?: ((value: number) => number) | undefined;
onAnimateEnd?: (newValue: T, finished: boolean) => void;
};
const value = useAnimatedValue<T>(value: T, options: Options<T>);
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT