diff --git a/attachments/02-basics/00-starting-project/App.js b/attachments/02-basics/00-starting-project/App.js new file mode 100644 index 00000000..eeadebd5 --- /dev/null +++ b/attachments/02-basics/00-starting-project/App.js @@ -0,0 +1,80 @@ +import { useState } from 'react'; +import { Button, FlatList, StyleSheet, View } from 'react-native'; +import GoalItem from './components/GoalItem'; +import GoalInput from './components/GoalInput'; +import { StatusBar } from 'expo-status-bar'; + +export default function App() { + const [courseGoals, setCourseGoals] = useState([]); + const [modalIsVisible, setModalIsVisible] = useState(false); + + function startAddGoalHandler() { + setModalIsVisible(true); + } + + function endAddGoalHandler() { + setModalIsVisible(false); + } + + function addGoalHandler(enteredGoalText) { + console.log(enteredGoalText); + setCourseGoals((prev) => [ + ...prev, + { text: enteredGoalText, id: Math.random().toString() } + ]); + endAddGoalHandler(); + } + + function deleteGoalHandler(id) { + setCourseGoals((prev) => { + return prev.filter((goal) => goal.id !== id); + }); + } + + return ( + <> + + +