File tree 4 files changed +45
-0
lines changed
4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ import type { Animated } from './Animated' ;
11
+
12
+ export function useAnimatedValue (
13
+ initialValue : number ,
14
+ config ?: Animated . AnimatedConfig ,
15
+ ) : Animated . Value ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type { AnimatedValueConfig } from './nodes/AnimatedValue' ;
12
+
13
+ import Animated from './Animated' ;
14
+ import { useRef } from 'react' ;
15
+
16
+ export default function useAnimatedValue (
17
+ initialValue : number ,
18
+ config ?: ?AnimatedValueConfig ,
19
+ ) : Animated . Value {
20
+ const ref = useRef ( null ) ;
21
+ if ( ref . current == null ) {
22
+ ref . current = new Animated . Value ( initialValue , config ) ;
23
+ }
24
+ return ref . current ;
25
+ }
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ import typeof * as Systrace from './Libraries/Performance/Systrace';
80
80
import typeof ToastAndroid from './Libraries/Components/ToastAndroid/ToastAndroid' ;
81
81
import typeof * as TurboModuleRegistry from './Libraries/TurboModule/TurboModuleRegistry' ;
82
82
import typeof UIManager from './Libraries/ReactNative/UIManager' ;
83
+ import typeof useAnimatedValue from './Libraries/Animated/useAnimatedValue' ;
83
84
import typeof useColorScheme from './Libraries/Utilities/useColorScheme' ;
84
85
import typeof useWindowDimensions from './Libraries/Utilities/useWindowDimensions' ;
85
86
import typeof UTFSequence from './Libraries/UTFSequence' ;
@@ -373,6 +374,9 @@ module.exports = {
373
374
return require ( './Libraries/ReactNative/RendererProxy' )
374
375
. unstable_batchedUpdates ;
375
376
} ,
377
+ get useAnimatedValue ( ) : useAnimatedValue {
378
+ return require ( './Libraries/Animated/useAnimatedValue' ) . default ;
379
+ } ,
376
380
get useColorScheme ( ) : useColorScheme {
377
381
return require ( './Libraries/Utilities/useColorScheme' ) . default ;
378
382
} ,
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export * from '../Libraries/ActionSheetIOS/ActionSheetIOS';
76
76
export * from '../Libraries/Alert/Alert' ;
77
77
export * from '../Libraries/Animated/Animated' ;
78
78
export * from '../Libraries/Animated/Easing' ;
79
+ export * from '../Libraries/Animated/useAnimatedValue' ;
79
80
export * from '../Libraries/AppState/AppState' ;
80
81
export * from '../Libraries/BatchedBridge/NativeModules' ;
81
82
export * from '../Libraries/Components/AccessibilityInfo/AccessibilityInfo' ;
You can’t perform that action at this time.
0 commit comments