-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
43 lines (37 loc) · 1.04 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, {Component} from 'react';
import {FlatList} from 'react-native';
import {getData} from './data/data';
import Item from './items/Item1';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {selected: {}, data: getData()};
// setInterval(() => {
// this.setState({data: getData()})
// }, 1000);
}
render() {
return (
<FlatList
data={this.state.data}
extraData={this.state.selected}
keyExtractor={(item) => item.id}
renderItem={({item}) => {
return (
<Item
{...item}
isSelected={this.state.selected[item.id]}
toggleSelected={(id) => {
if (this.state.selected[id]) {
this.setState({selected: {...this.state.selected, [id]: false}});
} else {
this.setState({selected: {...this.state.selected, [id]: true}});
}
}}
/>
);
}}
/>
);
}
}