Skip to content

Conversation

@hannojg
Copy link

@hannojg hannojg commented Jan 29, 2026

When using createAnimatedComponent with useAnimatedProps, props that are provided through animatedProps now become optional on the component itself.

This fixes the TypeScript error where required props would still be required on the component even when they were being provided via animatedProps.

Example:

interface ViewProps {
  requiredBorderRadius: number;
}
function MyComp(props: ViewProps) {}
const AnimatedComp = Animated.createAnimatedComponent(MyComp);

const animatedProps = useAnimatedProps(() => ({
  requiredBorderRadius: sharedValue.get()
}));

// Previously errored, now works correctly
<AnimatedComp animatedProps={animatedProps} />

Changes:

  • AnimatedProps<Props, AP> now takes optional second type parameter
  • useAnimatedProps preserves exact return type for better inference
  • Added AnimatedComponentType for generic animatedProps inference
  • Updated type tests to reflect new behavior

Summary

Test plan

When using createAnimatedComponent with useAnimatedProps, props that are
provided through animatedProps now become optional on the component itself.

This fixes the TypeScript error where required props would still be required
on the component even when they were being provided via animatedProps.

Example:
```tsx
interface ViewProps {
  requiredBorderRadius: number;
}
function MyComp(props: ViewProps) {}
const AnimatedComp = Animated.createAnimatedComponent(MyComp);

const animatedProps = useAnimatedProps(() => ({
  requiredBorderRadius: sharedValue.get()
}));

// Previously errored, now works correctly
<AnimatedComp animatedProps={animatedProps} />
```

Changes:
- AnimatedProps<Props, AP> now takes optional second type parameter
- useAnimatedProps preserves exact return type for better inference
- Added AnimatedComponentType for generic animatedProps inference
- Updated type tests to reflect new behavior

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant