diff --git a/app/App.js b/app/App.js index ed44375..f276f6a 100644 --- a/app/App.js +++ b/app/App.js @@ -1,105 +1,71 @@ -import React from 'react'; -import { - SafeAreaView, - StyleSheet, - ScrollView, - View, - Text, - StatusBar, -} from 'react-native'; - -import { - Header, - LearnMoreLinks, - Colors, - DebugInstructions, - ReloadInstructions, -} from 'react-native/Libraries/NewAppScreen'; +import React, {useRef, useState} from 'react'; +import {StyleSheet, View, FlatList, Button} from 'react-native'; +import GoalInput from './components/GoalInput'; +import GoalItem from './components/GoalItem'; const App = () => { + const [goals, setGoals] = useState([]); + const [isModalVisible, setIsModalVisible] = useState(false); + + const ref = useRef(null); + + const addGoalHandler = (goalTitle) => { + // setGoals([enteredGoal, ...goals]); + if (!goalTitle) { + return; + } + setGoals((currentGoals) => [ + {id: Math.random().toString(), value: goalTitle}, + ...currentGoals, + ]); + // setEnteredGoal(''); + ref.current.reset(); + setIsModalVisible(false); + }; + + const removeGoalHandler = (id) => { + setGoals((currentGoals) => currentGoals.filter((item) => item.id !== id)); + }; + return ( - <> - - - -
- {global.HermesInternal == null ? null : ( - - Engine: Hermes - - )} - - - Step One - - Edit App.js to change this - screen and then come back to see your edits. - - - - See Your Changes - - - - - - Debug - - - + +