I know that we can get the offset with
render() {
return <FlatList
onScroll={this.handleScroll}
/>
}
handleScroll = (event) => {
//get offset by using
//event.nativeEvent.contentOffset
}
But I'm not sure how to set it
To change the height of a FlatList in React Native, we can set the height of the View that we wrap around the FlatList . to set the height of the View to 300px to make the height of the FlatList 300px.
Use basic components The more complex your components are, the slower they will render. Try to avoid a lot of logic and nesting in your list items. If you are reusing this list item component a lot in your app, create a component only for your big lists and make them with as little logic and nesting as possible.
Now let's understand it, First of all we would get the selected item Id on item click event, Now we would use Data. filter() method with selected ID and remove the selected id then update the Data again using State. This would remove selected item from FlatList in react native.
To add a horizontal FlatList in React Native, we just set the horizontal prop of the FlatList to true . to add horizontal to FlatList . As a result, we can scroll through the FlatList items horizontally.
Unfortunately contentOffset didn't work for me. I ended up using contentContainerStyle that I found in the ScrollView documentation and it works great.
<FlatList
contentContainerStyle={{ paddingTop: 340 }}
data={data}
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With