/use-animated-value

Primary LanguageTypeScriptMIT LicenseMIT

@brigad/use-animated-value

One liner hook to get an Animated.Value from a value.

Installation

npm install @brigad/use-animated-value

or

yarn add @brigad/use-animated-value

Usage

import useAnimatedValue from "@brigad/use-animated-value";

const BoxWithAnimatedBackgroundColor = ({color}) => {
    const animatedColor = useAnimatedValue(color);

    return <Animated.View style={{backgroundColor: animatedColor}} />
}

API

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>);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT