Home.js 518 Bytes
import localforage from "localforage";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";

const Home = () => {
  console.log("visit Home");

  const navigate = useNavigate();
  useEffect(() => {
    async function where() {
      let destination;
      if (await localforage.getItem("session")) {
        destination = "/calendar/month";
      } else {
        destination = "/login";
      }
      navigate(destination);
    }

    where();
  }, [navigate]);
};

export default Home;