For FlatList: If you're working with a FlatList, the scrollTo method is not available. Instead, you should use scrollToOffset with the FlatList:
const scrollToTop = () => { flatListRef.current?.scrollToOffset({ offset: 0, animated: true });
};