blob: e6e04c0b96e9856be28e679c6dc39fd4021de671 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import React from 'react'
import {FlatList, Keyboard} from 'react-native'
export function useScrollToEndOnFocus(flatListRef: React.RefObject<FlatList>) {
React.useEffect(() => {
const listener = Keyboard.addListener('keyboardDidShow', () => {
requestAnimationFrame(() => {
flatListRef.current?.scrollToEnd({animated: true})
})
})
return () => {
listener.remove()
}
}, [flatListRef])
}
|