【发布时间】:2021-03-16 22:49:35
【问题描述】:
我想要做的是,当我运行 onPress 时,我想向下滚动到 y 的值(即 499)
但如果我使用我的代码,它什么都不起作用
这是我的代码
const TodoList = ({}) => {
const height = Dimensions.get('window').height;
const flatListRef = useRef()
return (
<FlatList
ref={flatListRef}
style={{height}}
keyExtractor={(item) => String(item.id)}
renderItem={({item}) => (
<TodoItem
onPress={() => {
const node = flatListRef.current;
if (node) {
node.scrollToIndex({x: 0, y: 499, animated: true, index:0});
}
}}
/>
)}
/>
我应该修复什么代码?...
【问题讨论】:
标签: javascript node.js reactjs react-native