UNPKG

336 BTypeScriptView Raw
1import * as React from 'react';
2import { Animated } from 'react-native';
3
4export default function useAnimatedValue(initialValue: number) {
5 const lazyRef = React.useRef<Animated.Value>();
6
7 if (lazyRef.current === undefined) {
8 lazyRef.current = new Animated.Value(initialValue);
9 }
10
11 return lazyRef.current as Animated.Value;
12}