Anonymous
FlatList не прокручивается
Сообщение
Anonymous » 25 июн 2024, 15:13
Я создал экран, на котором отображаю компонент, содержащий FlatList. Почему-то не могу пролистать список. Кто-то, кто сможет заметить мою ошибку и указать мне правильное направление?
функция рендеринга и стиль из моего файла экрана:
Код: Выделить всё
render() {
return (
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
overflow: 'hidden',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'flex-start',
},
list: {
flex: 1,
overflow: 'hidden',
},
});
функция и стиль рендеринга из моего компонента listitem:
Код: Выделить всё
export default class CardItem extends React.PureComponent {
render() {
return (
{this.props.title}
{this.props.date}
{this.props.hour}
);
}
}
const styles = StyleSheet.create({
cardview: {
flex: 1,
justifyContent: 'flex-start',
backgroundColor: 'white',
elevation: 3,
maxHeight: 200,
width: Dimensions.get('window').width - 20,
margin: 1,
marginTop: 10,
borderRadius: 4,
},
imagecontainer: {
flex: 7,
height: 140,
borderRadius: 4,
},
cardimage: {
flex: 1,
opacity: 0.8,
height: 140,
borderTopLeftRadius: 4,
borderTopRightRadius: 4,
},
cardinfo: {
flex: 2,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
padding: 10,
},
cardtitle: {
flex: 1,
fontSize: 16,
fontWeight: 'bold',
},
cardtext: {
flex: 1,
justifyContent: 'center',
alignItems: 'flex-end',
},
textdate: {
color: '#5e5e71',
},
texthour: {
color: '#5e5e71',
},
});
функция и стиль рендеринга из моего компонента списка:
Код: Выделить всё
export default class ActivityList extends React.Component {
_renderCardItem = ({ item }) => (
);
_keyExtractor = item => item.id;
render() {
return (
);
}
}
const styles = StyleSheet.create({
cardcontainer: {
flex: 1,
overflow: 'hidden',
backgroundColor: 'white',
alignItems: 'center',
width: Dimensions.get('window').width,
borderWidth: 0,
},
});
Все мои элементы данных имеют уникальный идентификатор, заголовок, дату и час.
Прочитайте все доступные руководства. и документы и не нашел решения.
Подробнее здесь:
https://stackoverflow.com/questions/486 ... -scrolling
1719317600
Anonymous
Я создал экран, на котором отображаю компонент, содержащий FlatList. Почему-то не могу пролистать список. Кто-то, кто сможет заметить мою ошибку и указать мне правильное направление? [b]функция рендеринга и стиль из моего файла экрана:[/b] [code]render() { return ( ); } } const styles = StyleSheet.create({ container: { flex: 1, overflow: 'hidden', backgroundColor: '#fff', alignItems: 'center', justifyContent: 'flex-start', }, list: { flex: 1, overflow: 'hidden', }, }); [/code] [b]функция и стиль рендеринга из моего компонента listitem:[/b] [code]export default class CardItem extends React.PureComponent { render() { return ( {this.props.title} {this.props.date} {this.props.hour} ); } } const styles = StyleSheet.create({ cardview: { flex: 1, justifyContent: 'flex-start', backgroundColor: 'white', elevation: 3, maxHeight: 200, width: Dimensions.get('window').width - 20, margin: 1, marginTop: 10, borderRadius: 4, }, imagecontainer: { flex: 7, height: 140, borderRadius: 4, }, cardimage: { flex: 1, opacity: 0.8, height: 140, borderTopLeftRadius: 4, borderTopRightRadius: 4, }, cardinfo: { flex: 2, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 10, }, cardtitle: { flex: 1, fontSize: 16, fontWeight: 'bold', }, cardtext: { flex: 1, justifyContent: 'center', alignItems: 'flex-end', }, textdate: { color: '#5e5e71', }, texthour: { color: '#5e5e71', }, }); [/code] [b]функция и стиль рендеринга из моего компонента списка:[/b] [code]export default class ActivityList extends React.Component { _renderCardItem = ({ item }) => ( ); _keyExtractor = item => item.id; render() { return ( ); } } const styles = StyleSheet.create({ cardcontainer: { flex: 1, overflow: 'hidden', backgroundColor: 'white', alignItems: 'center', width: Dimensions.get('window').width, borderWidth: 0, }, }); [/code] Все мои элементы данных имеют уникальный идентификатор, заголовок, дату и час. Прочитайте все доступные руководства. и документы и не нашел решения. Подробнее здесь: [url]https://stackoverflow.com/questions/48674848/flatlist-not-scrolling[/url]