Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 7d75b63

Browse files
authored
Add style prop to every animated component (software-mansion#2947)
1 parent 7a687ec commit 7d75b63

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

react-native-reanimated-tests.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ const AnimatedFCWithRef = Animated.createAnimatedComponent(SomeFCWithRef);
8181

8282
function CreateAnimatedComponentTest1() {
8383
const animatedProps = useAnimatedProps(() => ({ fill: 'blue' }));
84-
return <AnimatedPath animatedProps={animatedProps} />;
84+
return (
85+
<AnimatedPath
86+
animatedProps={animatedProps}
87+
style={{ backgroundColor: 'red' }}
88+
/>
89+
);
8590
}
8691

8792
function CreateAnimatedComponentTest2() {

react-native-reanimated.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,14 @@ declare module 'react-native-reanimated' {
146146
>;
147147
};
148148

149-
export type AnimateProps<P extends object> = {
150-
[K in keyof P]: K extends 'style'
151-
? StyleProp<AnimateStyle<P[K]>>
152-
: P[K] | AnimatedNode<P[K]>;
149+
export type StylesOrDefault<T> = 'style' extends keyof T
150+
? T['style']
151+
: Record<string, unknown>;
152+
153+
export type AnimateProps<P extends Record<string, unknown>> = {
154+
[K in keyof P]: P[K] | AnimatedNode<P[K]>;
155+
} & {
156+
style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
153157
} & {
154158
animatedProps?: Partial<AnimateProps<P>>;
155159
layout?:

0 commit comments

Comments
 (0)