I’m looking for a method to scroll to a specific position when clicking a button in React. It’s easy in React with scrollIntoView, but in React Native, nothing is simple ^^’ and I can’t find a method to do it :/ I tried with useRef and scrollTo on ScrollViews, but it doesn’t work.
If anyone has any suggestions, I’m all ears.
const scrollViewRef = useRef(null);
const section3Ref = useRef(null);
const scrollToSection = () => {
if (scrollViewRef.current) {
scrollViewRef.current.scrollTo({ y: 200});
}
};
return( <Architecture ref={scrollViewRef}>
<Button title="Scroll to Section 3" onPress={scrollToSection} />
<View ref={section3Ref}>
<VeterinarianPet />
</View>
</Architecture>
)
I would like that when I click on the button it scrolls to the veterinarian component
sorry in advance for my english