about summary refs log tree commit diff
path: root/src/lib/hooks/useAnimatedValue.ts
blob: 9ae14dab6287db53d71b378b3e1d0b604544b901 (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>(undefined)

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

  return lazyRef.current as Animated.Value
}