Elements before FlatList are fixed on a page and doesn't scroll with FlatList
Tag : css , By : Star Gryphon
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further If I do understand you correctly you want to have your view on top be a part of the scrollable area of your FlatList. So you may want to make the view on top the ListHeaderComponent renderListHeader = () => {
return (
<View>
<Text>Foo</Text>
</View>
);
}
render() {
return (
<FlatList
data={this.props.data}
extraData={this.state}
keyExtractor={this._keyExtractor}
renderItem={this._renderItem}
ListHeaderComponent={this.renderListHeader}
/>
);
}
|
React Native FlatList with other Component doesn't scroll to the end
Date : March 29 2020, 07:55 AM
may help you . Wrap Flatlist with style={{flex:1}}. If it does not work add marginBottom to flatlist <View style={{flex:1}}>
<FlatList
data={this.props.produk}
renderItem={({ item }) =>
<View key={item.id} >
<Image resizeMode="cover" source={{ uri: item.thumb }} style={styles.fotoProduk} />
</View>
}
keyExtractor={(item, index) => index}/>
</View>
|
FlatList scroll with the static component
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Flatlist has a prop ListHeaderComponent which accepts a JSX element. So: import React from "react";
import { View, Text, FlatList } from "react-native";
...
class FlatListScrollWithStatic extends React.Component {
render() {
return (
<View style={{ flex: 1 }}>
<FlatList
style={{ flex: 1 }}
data={this.props.friendsCard}
renderItem={({ item }) => <FriendsCard {...item} />} // the for loop rendered components
keyExtractor={(item, index) => index.toString()}
ListHeaderComponent={<FriendsTop />}
/>
</View>
);
}
}
|
FlatList scroll to top while FlatList in child component
Date : March 29 2020, 07:55 AM
Hope that helps I am quite new to react native and would like to ask how to scroll to top when tap on button in a FlatList. However, in my case, the FlatList is inside a child component which I don't know how to pass the ref around. , Try the following, _didTapOnButton=()=>{
setTimeout(() => {
if (this.timerFlatlistRef)
this.timerFlatlistRef.scrollToIndex({
animated: true,
index: 0,
});
}, 1000);
}
_getItemLayout = (data, index) => ({
length: 24,
offset: 100 * index,
index
});
_renderItems = ({ item, index }) => {
...
...
}
...
<FlatList
ref={ref => (this.timerFlatlistRef = ref)}
style={{ flex: 1, paddingTop: 10 }}
data={dayHours}
getItemLayout={this._getItemLayout}
renderItem={this._renderItems}
keyExtractor={(item, index) => String(index)}
extraData={this.state}
/>
...
|
how to make flatlist component of react-native scroll to bottom when its first rendered?
Date : March 29 2020, 07:55 AM
I hope this helps . Basically you need to use scrollToEnd on flatList.. First: create a flatList reference with: ref={ (ref) => { this.myFlatListRef = ref } }
onContentSizeChange={ () => { this.myFlatListRef.scrollToEnd({animated:true}) } }
onLayout={ () => { this.myFlatListRef.scrollToEnd({animated:true}) } }
<FlatList
ref={ (ref) => { this.myFlatListRef = ref } }
onContentSizeChange={ () => { this.myFlatListRef.scrollToEnd({animated:true}) } }
onLayout={ () => { this.myFlatListRef.scrollToEnd({animated:true}) } }
data={this.state.messages}
renderItem={ ({item}) => <Item data={item} /> }
/>
|