Scroll to end of FlatList after displaying the keyboard

I’m making a chat component and I want about the same things. Did it like this: <FlatList ref={ref => this.flatList = ref} onContentSizeChange={() => this.flatList.scrollToEnd({animated: true})} onLayout={() => this.flatList.scrollToEnd({animated: true})} … /> Keyboard popping up triggers a layout, so that’s fixed. New chat messages arriving trigger content changes, so it also scrolls to the bottom … Read more

How to get currently visible index in RN flat list

UPD. thanks to @ch271828n for pointing that onViewableItemsChanged shouldn`t be updated You can use FlatList onViewableItemsChanged prop to get what you want. class Test extends React.Component { onViewableItemsChanged = ({ viewableItems, changed }) => { console.log(“Visible items are”, viewableItems); console.log(“Changed in this iteration”, changed); } render () => { return ( <FlatList onViewableItemsChanged={this.onViewableItemsChanged } viewabilityConfig={{ … Read more

VirtualizedList: You have a large list that is slow to update

I was previously seeing this error. After optimizing my code, I no longer see it. I figured out the problem by adding console.log() statement to the render() function of the Component that creates the FlatList, and the function that renders each item in the List. I noticed that my code was previously re-rendering the entire … Read more

How to re-render flatlist?

Use the extraData property on your FlatList component. As the documentation states: By passing extraData={this.state} to FlatList we make sure FlatList will re-render itself when the state.selected changes. Without setting this prop, FlatList would not know it needs to re-render any items because it is also a PureComponent and the prop comparison will not show … Read more

tech