import React, { useEffect } from "react"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import { useDispatch } from "react-redux"; import { actions, useTypedSelector } from "./store"; import { Link } from "react-router-dom"; import { getClient } from "./contentful"; import type { Book } from "./store"; const App: React.FC = () => { const dispatch = useDispatch(); const { isLoading, books } = useTypedSelector((state) => ({ isLoading: state.isLoading, books: state.books, })); useEffect(() => { async function fetchData() { const entries = await getClient().getEntries(); const books = entries.items.map((x) => x.fields) as Book[]; dispatch(actions.setBooks(books)); } fetchData(); }, []); return (

Books

    {books.map((book) => (
  • {book.title} {book.author}

  • ))}
); }; export default App;