According to this source code Animated.event traverses the objects passed as arguments of it until finds an instance of AnimatedValue.
Then this key (where the AnimatedValue has been found) is applied to the callback (onScroll) and the value at the key of the event passed to the scroll is assigned to this AnimatedValue.
In the code:
const animatedValue = useRef(new Animated.Value(0)).current;
...
onScroll={Animated.event(
[{nativeEvent: {contentOffset: {y: animatedValue}}}]
)}
is the same as
const animatedValue = useRef(new Animated.Value(0)).current;
...
onScroll={({nativeEvent: { contentOffset: {y} }}) => {
animatedValue.setValue(y);
}}
If your callback accepts more than one event (argument), then just put the mapping object at the needed index (thus the array as the argument of Animated.value.
onScroll={Animated.event(
[
{}, // <- disregard first argument of the event callback
{nativeEvent: {contentOffset: {y: animatedValue}}} // <- apply mapping to the second
]
)}