In a React Native component, I have: <Animated.ScrollView ref={cardRef} ... />.
When I hover on top of ref I see (JSX attribute) React.ClassAttributes<Animated.ScrollView>.ref?: React.LegacyRef<Animated.ScrollView> | undefined, so I create the ref like so const cardRef = useRef<React.RefObject<Animated.ScrollView> | undefined>(undefined); but doing cardRef.current?.scrollTo({ x: newOffset }); gives me a warning for scrollTo: Property 'scrollTo' does not exist on type 'RefObject<ScrollView>'.
How can I know what the right TS definition of it should be? Is there a way or is it always a guessing game?