-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
63 lines (53 loc) · 1.38 KB
/
App.js
File metadata and controls
63 lines (53 loc) · 1.38 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
62
63
import React, { useState } from "react";
import { View, Text, StatusBar, StyleSheet } from "react-native";
import GoalList from "./GoalList";
import GoalInput from "./GoalInput";
const defaultGoals = [
"Faire les courses",
"Aller à la salle de sport 3 fois par semaine",
"Monter à plus de 5000m d'altitude",
"Acheter mon premier appartement",
"Perdre 5 kgs",
"Gagner en productivité",
"Apprendre un nouveau langage",
"Faire une mission en freelance",
"Organiser un meetup autour de la tech",
"Faire un triathlon",
];
const App = () => {
const [goals, setGoals] = useState(defaultGoals);
const addGoal = (newGoal) => {
if (newGoal.trim() !== "") {
setGoals([...goals, newGoal]);
}
};
const deleteGoal = (index) => {
const updatedGoals = [...goals];
updatedGoals.splice(index, 1);
setGoals(updatedGoals);
};
return (
<View style={styles.container}>
<Text style={styles.red}>Mes objectifs</Text>
<GoalList goals={goals} onDeleteGoal={deleteGoal} />
<GoalInput onAddGoal={addGoal} />
<StatusBar style="auto" />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
padding: 16,
},
red: {
color: "red",
fontWeight: "bold",
fontSize: 20,
marginBottom: 10,
},
});
export default App;