1
Next people, I have a flat list in my React Native app, where in it I need to use a "ref" to access her "scrollToEnd()" method, but how I’m using Hooks I can’t use the ref.
Here’s an example of what I want to do:
export default function Test(){
return(
<FlatList data={data}
keyExtractor={id => String(id)}
ref={ref.flatlist}
onContentSizeChange={ref.flatlist.scrollToEnd()}
renderItem={(item) => <Text>{item}</Text>
/>
)
}
remembering that the above code is an example, but it explains more or less what I want to do. Does anyone know how to use that ref on the Hooks or use methods of the React components on the hook without needing these refs? (the scrollToEnd() method I took from the Flatlist documentation)
thank you very much kkkk, I started using with classes even pq the answer was taking dms but I did a test here and it really worked ent if I need elsewhere already know how to do thank you!
– Elon Neto
You’re welcome, good luck!
– Tulio Calil