Getting undefined when calling scrollToIndex from the component.
Sorry, was using the wrong ref.
@cristianoccazinsp could you please elaborate on how you solved this? thanks
I stopped using this library a while ago so I can't really recall what was the right way to obtain a ref to the original flat list, but it should be simple to debug and find it out!
For whoever stumbles upon this in the future, I managed to solve this problem by doing this:
const scrollRef = useRef<{ flatListRef: Element | undefined }>({ flatListRef: undefined });
...
(scrollRef.current?.flatListRef as any).scrollToIndex(); //scrollToIndex() works
...
<KeyboardAwareFlatList
innerRef={(ref) => (scrollRef.current.flatListRef = ref)}
...
Hi,
this approach does not work for me using class components. However, a different one does, namely by using callback refs.
Thanks mlthlschr,
Your solution worked for me in combination of using innerRef prop of the keyboardAwareFlatlist