diff --git a/public/index.html b/public/index.html index aa069f2..5267568 100644 --- a/public/index.html +++ b/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + React + Typescript App! diff --git a/src/components/App.tsx b/src/components/App.tsx index e83bc08..b57b57a 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -30,9 +30,9 @@ function GetPeople() { const [favoriteCards, setFavoriteCards] = useState([]); const [showFavorites, setShowFavorites] = useState(false); - const queryClient = useQueryClient() - + // Get list of favorites from dyamoDB const { isLoading, error, data } = useQuery('people', () => + // Lambda API Gateway fetch('https://w5c9dy2dg4.execute-api.us-east-2.amazonaws.com/people', { headers: { 'Content-Type': 'application/json', @@ -43,13 +43,16 @@ function GetPeople() { ) ); + // Updates the local favorites list useEffect(() => { if (data) { setFavoriteCards(data.map(person => parseInt(person.id))); } }, [data]); - console.log(favoriteCards); + if (isLoading) return (

Loading...

); + + if (error) return (

Error fetching data.

); const handleInputChange = (event: React.ChangeEvent) => { const value = parseInt(event.target.value);