forked from necolas/react-native-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a missing
useAnimatedValue
hook
Issue: necolas#2707
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
packages/react-native-web/src/exports/Animated/useAnimatedValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Davyd Narciso. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use client'; | ||
|
||
import useAnimatedValue from '../../vendor/react-native/Animated/useAnimatedValue'; | ||
export default useAnimatedValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/react-native-web/src/vendor/react-native/Animated/useAnimatedValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
import type {AnimatedValueConfig} from './nodes/AnimatedValue'; | ||
|
||
import Animated from './Animated'; | ||
import {useRef} from 'react'; | ||
|
||
export default function useAnimatedValue( | ||
initialValue: number, | ||
config?: ?AnimatedValueConfig, | ||
): Animated.Value { | ||
const ref = useRef<null | Animated.Value>(null); | ||
if (ref.current == null) { | ||
ref.current = new Animated.Value(initialValue, config); | ||
} | ||
return ref.current; | ||
} |