Skip to content

Commit

Permalink
Align useAnimatedValue with OSS types (#49643)
Browse files Browse the repository at this point in the history
Summary:

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
Aligns `useAnimatedValue.js` with its manual .d.ts types.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D70096210
  • Loading branch information
iwoplaza authored and facebook-github-bot committed Feb 26, 2025
1 parent 474cece commit 465f31b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export {default as Node} from './nodes/AnimatedNode';
export {default as Value} from './nodes/AnimatedValue';
export {default as ValueXY} from './nodes/AnimatedValueXY';

export type {AnimatedValueConfig as AnimatedConfig} from './nodes/AnimatedValue';

export const add = AnimatedImplementation.add;
export const attachNativeEvent = AnimatedImplementation.attachNativeEvent;
export const createAnimatedComponent =
Expand Down
4 changes: 1 addition & 3 deletions packages/react-native/Libraries/Animated/useAnimatedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
* @format
*/

import type {AnimatedValueConfig} from './nodes/AnimatedValue';

import Animated from './Animated';
import {useRef} from 'react';

export default function useAnimatedValue(
initialValue: number,
config?: ?AnimatedValueConfig,
config?: ?Animated.AnimatedConfig,
): Animated.Value {
const ref = useRef<null | Animated.Value>(null);
if (ref.current == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export { default as Interpolation } from \\"./nodes/AnimatedInterpolation\\";
export { default as Node } from \\"./nodes/AnimatedNode\\";
export { default as Value } from \\"./nodes/AnimatedValue\\";
export { default as ValueXY } from \\"./nodes/AnimatedValueXY\\";
export type { AnimatedValueConfig as AnimatedConfig } from \\"./nodes/AnimatedValue\\";
declare export const add: $FlowFixMe;
declare export const attachNativeEvent: $FlowFixMe;
declare export const createAnimatedComponent: $FlowFixMe;
Expand Down Expand Up @@ -1006,7 +1007,7 @@ exports[`public API should not change unintentionally Libraries/Animated/useAnim
exports[`public API should not change unintentionally Libraries/Animated/useAnimatedValue.js 1`] = `
"declare export default function useAnimatedValue(
initialValue: number,
config?: ?AnimatedValueConfig
config?: ?Animated.AnimatedConfig
): Animated.Value;
"
`;
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build-types/buildTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ENTRY_POINTS = [
'packages/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js',
'packages/react-native/Libraries/Alert/Alert.js',
'packages/react-native/Libraries/Animated/Animated.js',
'packages/react-native/Libraries/Animated/useAnimatedValue.js',
'packages/react-native/Libraries/AppState/AppState.js',
'packages/react-native/Libraries/BatchedBridge/NativeModules.js',
'packages/react-native/Libraries/Blob/Blob.js',
Expand Down

0 comments on commit 465f31b

Please sign in to comment.