-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (39 loc) · 1.05 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
43
44
45
import { useState } from "react";
import { StyleSheet, Text, View } from "react-native";
import { ListGoalComponent, InputBarComponent } from "./components";
const App = () => {
const [listGoal, setListGoal] = useState([]);
const onAddGoalToList = (newGoal) =>
setListGoal((prevVal) => [
{ id: Math.random(), name: newGoal },
...prevVal,
]);
const onRemoveGoalFromList = (idGoal) => {
setListGoal((prevVal) => prevVal.filter((goal) => goal.id !== idGoal));
};
return (
<View style={styles.container}>
<Text style={styles.titlestart}>ToDo Goals</Text>
<InputBarComponent onAddGoalToList={onAddGoalToList} />
<ListGoalComponent
listGoal={listGoal}
onRemoveGoalFromList={onRemoveGoalFromList}
/>
</View>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 50,
paddingHorizontal: 16,
},
titlestart: {
fontSize: 40,
textAlign: "center",
marginBottom: 20,
color: "#5e0acc",
// fontFamily: "Bigelow Rules",
},
});