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

import { dataForage } from "../utils/LocalForage";

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

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

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

export default Home;