API

useScreenAnimation

Read transition interpolation props from a component.

useScreenAnimation() returns a Reanimated derived value with the same interpolation props passed to screenStyleInterpolator.

TSX

1import { useScreenAnimation } from "react-native-screen-transitions";
2
3const animation = useScreenAnimation();
4
5const style = useAnimatedStyle(() => {
6 const { current } = animation.value;
7
8 return {
9 opacity: current.progress,
10 transform: [{ translateY: current.gesture.y }],
11 };
12});

Target another transition scope with depth:

TSX

1const currentAnimation = useScreenAnimation({ depth: 0 });
2const parentAnimation = useScreenAnimation({ depth: -1 });
3const childAnimation = useScreenAnimation({ depth: 1 });

depth: 0 resolves the current transition. Negative values resolve ancestors. Positive values resolve descendants.

Non-current targets can return null, so check animation.value before reading it.

Legacy string targets such as "self", "parent", and "root" still work, but new code should use { depth }.