Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

ReactNative Animated.ScrollView ref TypeScript definition

$
0
0

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?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>