我正在尝试在本机反应中创建一个 Listview,每一行都有一个复选框和一个正文。为此,我使用的是 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;