-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
61 lines (55 loc) · 1.47 KB
/
Copy pathApp.js
File metadata and controls
61 lines (55 loc) · 1.47 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, {useState} from 'react';
// import text, stylesheet
import {View, StyleSheet, FlatList, Alert} from 'react-native';
import Header from './components/Header';
import ListItem from './components/listItem';
import AddItem from './components/addItem';
// import PrintingFile from './components/printingFile';
// import NewButton from './components/newModuleButton';
// import ABC from './CustomModule';
const App = () => {
// ABC.show();
const [items, setItems] = useState([
{id: 120, text: 'Tires'},
{id: 2000, text: 'Brakes'},
{id: 323, text: 'Alignment'},
{id: 448, text: 'Balancing'},
{id: 105, text: 'Oil Change'},
{id: 603, text: 'Car diagnostics'},
]);
// console.log(uuid());
// uuidv4();
const deleteItem = id => {
setItems(prevItems => {
return prevItems.filter(item => item.id !== id);
});
};
const addItem = item => {
if (!item) {
Alert.alert('cannot enter empty text');
} else {
setItems(prevItems => {
return [{id: 7, text: item}, ...prevItems];
});
}
};
return (
<View style={styles.container}>
<Header title="Rovo Auto Center" />
<AddItem addItem={addItem} />
<FlatList
data={items}
renderItem={({item}) => (
<ListItem item={item} deleteItem={deleteItem} />
)}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
paddingTop: 50,
backgroundColor: '#fff',
},
});
export default App;