// Create a reference to the ScrollView
const scrollViewRef = useRef(null);

// Scroll handler
const onScrollToTop = () => {
  if (scrollViewRef.current) {
    scrollViewRef.current.scrollTo({ x: 0, y: 0, animated: true }); //animated: true for smooth scrolling
  }
};

// Render the ScrollView and Button
<ScrollView ref={scrollViewRef}>
  </ScrollView>
<TouchableOpacity 
onPress={onScrollToTop}
>
<Text>{“Go to Top”></Text>
</TouchableOpacity>

 

Support On Demand!

                                         
React Native