about summary refs log tree commit diff
path: root/src/view/lib/hooks/useAnimatedValue.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/lib/hooks/useAnimatedValue.ts')
-rw-r--r--src/view/lib/hooks/useAnimatedValue.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/view/lib/hooks/useAnimatedValue.ts b/src/view/lib/hooks/useAnimatedValue.ts
new file mode 100644
index 000000000..1307ef952
--- /dev/null
+++ b/src/view/lib/hooks/useAnimatedValue.ts
@@ -0,0 +1,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
+}