-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
executable file
·35 lines (32 loc) · 999 Bytes
/
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
import { StatusBar } from "expo-status-bar";
import { StyleSheet, View, FlatList, SafeAreaView } from "react-native";
import React, { useState } from "react";
import GoatItem from "./components/GoatItem";
import GoalInput from "./components/GoatInput";
export default function App() {
const [courseGoals, setCourseGoals] = useState([]);
const addGoalHandler = (goalTitle) => {
setCourseGoals((currentGoals) => [
...currentGoals,
{ text: goalTitle, id: Math.random().toString() },
]);
};
return (
<SafeAreaView style={styles.container}>
<GoalInput onAddGoal={addGoalHandler} />
<FlatList
keyExtractor={(item, index) => item.id}
data={courseGoals}
renderItem={(itemData) => <GoatItem title={itemData.item.text} />}
/>
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: StatusBar.currentHeight || 0,
backgroundColor: "#fff",
},
});