Guest User

Untitled

a guest
Mar 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. data: [ {id: 0, key: 'Key1', checked: false }, ... }]
  2.  
  3. onCheckBoxChange(id) {
  4. let arr = Array.from(Object.create(this.state.data));
  5. arr[id].checked = !arr[id].checked;
  6. this.setState({
  7. data: arr
  8. })
  9. }
  10.  
  11. render() {
  12. return (
  13. <Container>
  14. <Content>
  15. <List dataArray={this.state.data}
  16. renderRow={(item) =>
  17. <View>
  18. <ListItem>
  19. <CheckBox checked={ this.state.data[item.id].checked }
  20. onPress={()=> this.onCheckBoxChange(item.id)}/>
  21. <Text>{item.key}</Text>
  22. </ListItem>
  23. </View>
  24. }>
  25. </List>
  26. </Content>
  27. </Container>
  28. )
  29. }
  30. }
Add Comment
Please, Sign In to add comment