react-native-animatable
react-native-animatable copied to clipboard
Ref assign problem
I am using blow code block, but I am getting
dataListRef.scrollToOffset is not a function. (In 'dataListRef.scrollToOffset({ animated: true, offset: 0 })', 'dataListRef.scrollToOffset' is undefined)
error when I try this
this.dataListRef.scrollToOffset({ animated: true, offset: 0 });
<AnimatableFlatList
useNativeDriver
ref={ref => {
this.dataListRef = ref;
}}
/>
Does it work when you do this.dataListRef.current.scrollToOffset({animated: true, offset: 0)} ?
I am sorry, It didn't worked. @shauns
May be a better solution, but managed to get it working by doing the following:
this.dataListRef.current.ref.getNode().scrollToOffset(...);
The getNode() should return the actual element (FlatList in this example) so you can use the methods on it.