Я пытаюсь создать Listview в React Native, в каждой строке есть флажок и основной текст. Для этого я использую пакет nativebase. http://nativebase.io/docs/v2.0.0/components#checkbox
У меня есть некоторые проблемы, когда я нажимаю на флажок, флажок не меняет состояние на false. Как я могу получить значение из основного текста, когда я нажимаю на флажок?
import React, { Component } from 'react';
import { Container, Content, List, Body, ListItem, Text, CheckBox } from 'native-base';
class ListExample extends Component {
state = {
pressed: true,
value: ""
};
onCheckBoxPress() {
console.log(this);
this.setState({ pressed: false});
this.setState({ value: BODYVALUE});
}
render() {
var items = [ "test1", "test2", "test3", "test4", "test5", "test6" ];
return (
<Container>
<Content>
<List dataArray={items} renderRow={(data) =>
<ListItem>
<CheckBox onPress={this.onCheckBoxPress.bind(this)} checked={this.state.pressed} />
<Body>
<Text>{data}</Text>
</Body>
</ListItem>
} />
</Content>
</Container>
);
}
}
export default ListExample;