[Android][Flatlist][Horizontal] Last item delete in horizontal flatlist does not adjust scroll position.
See original GitHub issueReact Native version: 0.59.10
Steps To Reproduce
export default class App extends Component<Props> {
constructor(props) {
super(props);
this.dataItems = [{
id: 1,
text: 'one'
},{
id: 2,
text: 'two'
},{
id: 3,
text: 'three'
}, {
id: 4,
text: 'four',
}, {
id: 5,
text: 'five'
}];
}
removeItem = (id) => {
this.dataItems = this.dataItems.filter((item) => item.id !== id);
this.setState({});
};
renderItem = ({item}) => {
return (
<View style={{ width: 140, height: 140, backgroundColor: 'yellow', margin: 10}}>
<Text>{item.text}</Text>
<TouchableOpacity onPress={() => {
this.removeItem(item.id);
}}>
<Text>{'Remove me'}</Text>
</TouchableOpacity>
</View>
)
};
render() {
return (
<View style={styles.container}>
<View style={{height: 140, width: '100%'}}>
<FlatList
horizontal
data={this.dataItems}
renderItem={this.renderItem}
keyExtractor={item => `${item.id}`}
/>
</View>
</View>
);
}
}
Describe what you expected to happen: After removing last item, scroll position should be adjusted.
Snack, code example, screenshot, or link to a repository:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:19
Top Results From Across the Web
React Native FlatList not scrolling to end - Stack Overflow
I just passed a view with the preferable height and it worked for me perfectly. Here is the code snippet: <FlatList data={DATA} renderItem={({ ......
Read more >Common bugs in React Native ScrollView and how to fix them
After putting all those elements inside the ScrollView component, you can use it to scroll through them vertically (the default) or horizontally ......
Read more >ScrollView - React Native
FlatList renders items lazily, when they are about to appear, ... the scroll view bounces horizontally when it reaches the end even if...
Read more >Building a Smooth Image Carousel with FlatList in React Native
Users can scroll through items by dragging across right or left to ... the end of the carousel, to help position the first...
Read more >React Native scrollToIndex - Dynamic size item scroll inside ...
In this video tutorial you will learn about React Native scrollToIndex and how to scroll to an item inside a FlatList, ListView, ScrollView, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same problem here.
A workaround while waiting fix: use scrollToEnd when removing the last item.
Example:
latest pr is https://github.com/facebook/react-native/pull/28977