about summary refs log tree commit diff
path: root/src/lib/hooks/useAnimatedValue.ts
blob: 1307ef95229f51536395d0ea257d3dfb4d4bd7af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import * as React from 'react'
import {Animated} from 'react-native'

export function useAnimatedValue(initialValue: number) {
  const lazyRef = React.useRef<Animated.Value>()

  if (lazyRef.current === undefined) {
    lazyRef.current = new Animated.Value(initialValue)
  }

  return lazyRef.current as Animated.Value
}