How to make fixed Header and Footer with Scrollable body

I have created a modal popup with sliding effect but the issue that I’m facing is, I want to make the modal body scrollable but the Header and Footer should remain at their exact position without any overflow. I tried many times but I don’t know where i am doing mistake, so if you give your little time to find out my problem it will be very helpful for me.

    var drawer = function () {
      if (!Element.prototype.closest) {
        if (!Element.prototype.matches) {
          Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
        }
        Element.prototype.closest = function (s) {
          var el = this;
          var ancestor = this;
          if (!document.documentElement.contains(el)) return null;
          do {
            if (ancestor.matches(s)) return ancestor;
            ancestor = ancestor.parentElement;
          } while (ancestor !== null);
          return null;
        };
      }    

      var settings = {
        speedOpen: 50,
        speedClose: 350,
        activeClass: 'is-active',
        visibleClass: 'is-visible',
        selectorTarget: '[data-drawer-target]',
        selectorTrigger: '[data-drawer-trigger]',
        selectorClose: '[data-drawer-close]',
      };

      var toggleAccessibility = function (event) {
        if (event.getAttribute('aria-expanded') === 'true') {
          event.setAttribute('aria-expanded', false);
        } else {
          event.setAttribute('aria-expanded', true);
        }   
      };

      var openDrawer = function (trigger) {
        var target = document.getElementById(trigger.getAttribute('aria-controls'));
        target.classList.add(settings.activeClass);
        document.documentElement.style.overflow = 'hidden';
        toggleAccessibility(trigger);
        setTimeout(function () {
          target.classList.add(settings.visibleClass);
          trapFocus(target);
        }, settings.speedOpen); 
      };

      var closeDrawer = function (event) {
        var closestParent = event.closest(settings.selectorTarget),
          childrenTrigger = document.querySelector('[aria-controls="' + closestParent.id + '"');
        closestParent.classList.remove(settings.visibleClass);
        document.documentElement.style.overflow = '';
        toggleAccessibility(childrenTrigger);
        setTimeout(function () {
          closestParent.classList.remove(settings.activeClass);
        }, settings.speedClose);             
      };

      var clickHandler = function (event) {
        var toggle = event.target,
          open = toggle.closest(settings.selectorTrigger),
          close = toggle.closest(settings.selectorClose);
        if (open) {
          openDrawer(open);
        }
        if (close) {
          closeDrawer(close);
        }
        if (open || close) {
          event.preventDefault();
        }

      };

      var keydownHandler = function (event) {
        if (event.key === 'Escape' || event.keyCode === 27) {
          var drawers = document.querySelectorAll(settings.selectorTarget), i;
          for (i = 0; i < drawers.length; ++i) {
            if (drawers[i].classList.contains(settings.activeClass)) {
              closeDrawer(drawers[i]);
            }
          }
        }
      };

      document.addEventListener('click', clickHandler, false);
      document.addEventListener('keydown', keydownHandler, false); 
    };
    drawer();
.plans-modal .drawer-left .modal-content {
  background-color: #2b2f4b;
}

.plans-modal .drawer-left .modal-body .plan-card-1 {
  background-color: #1f2236;
  border: 3px solid #e8576f;
  border-radius: 15px;
  margin: 20px;
}

.plans-modal .drawer-left .modal-body .card-title {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  color:#e8576f;
  padding: 12px 0px;
  margin: 0;
}

.plans-modal .drawer-left .modal-body .card-hr {
  margin:0 auto;
  max-width:85%;
  background-color: #e8576f;
  height: 2px; 
  border: 0;
}

.plans-modal .drawer-left .plan-price {
  margin: 0 auto;
  text-align: center;
  padding: 12px 0px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #e8576f;
} 

.plans-modal .drawer-left .modal-body .card-items {
  display: flex;
  justify-content: center;
  align-items: center;
}

.plans-modal .drawer-left .modal-body .card-items ul {
        margin: 0;
        padding: 20px 15px;
}

.plans-modal .drawer-left .modal-body .card-items ul li {
  list-style-type: none;
  font-size: 14px;
  color: #fff;
}

.plans-modal .drawer-left .modal-body .card-items ul li .fa-arrow-circle-right {
  margin-right: 4px;
  color: #e8576f;
}

.plans-modal .drawer-left .modal-body .card-items ul li:not(:last-child) {
  padding-bottom: 14px;
}


/*---------------------------- HEADER -------------------------*/    

.plans-modal .drawer-left .modal-content {
  height: 100vh;
  border: 5px solid #e8576f;
  border-left: none;
  border-top-right-radius:15px;
  border-bottom-right-radius:15px;
}

.plans-modal .drawer-left .modal-header {
  background-color: #1f2236;
  border-top-right-radius:10px;
  border-bottom: 4px solid #e8576f;
  height: 70px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.plans-modal .drawer-left .modal-header .modal-logo-title {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.plans-modal .drawer-left .modal-header img {
  height: 40px;
  width: 40px;
  margin-right: 10px;
}

/*---------------------------- HEADER -------------------------*/ 


/*---------------------------- FOOTER -------------------------*/ 

.plans-modal .drawer-left .modal-footer {
  background-color: #1f2236;
  border-bottom-right-radius:10px;
  border-top: 4px solid #e8576f;
  height: 70px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.plans-modal .drawer-left .modal-footer .plans-btns {
  display: flex;
  margin-right: 55%;
  font-size: 22px;
  color: #e8576f;
  cursor: pointer;
}

.plans-modal .drawer-left .modal-footer .plans-btns #btnUp:hover {
  color: #fff;
  transition: 0.5s ease;
}

.plans-modal .drawer-left .modal-footer .plans-btns #btnDown:hover {
  color: #fff;
  transition: 0.5s ease;
}

.plans-modal .drawer-left .modal-footer .plans-btns #btnDown {
  margin-left: 7px;
}

.plans-modal .drawer-left .modal-footer .close-btn {
  padding: 5px 12px;
  background:#e8576f;
  color:#fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  border: none;
}

.plans-modal .drawer-left .modal-footer .close-btn:hover {
  background: #fff;
  color: #e8576f;
  transition: 0.5s ease;
}

/*---------------------------- FOOTER -------------------------*/ 


/* ------------------ ONLY SLIDER CODE ----------------*/

    .drawer {
      display: none;
    }
    .drawer-overlay {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      width: 100%;
      z-index: 200;
      opacity: 0;
      transition: opacity 0.3s;
      will-change: opacity;
      background-color: #000;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;      
    }

    .drawer-wrapper {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      height: 100%;
      width: 100%;
      z-index: 9999;
      overflow: auto;
      transition: transform 0.5s;
      will-change: transform;
      background-color: transparent;
      /* display: flex;
      flex-direction: column;  */
      /* -webkit-overflow-scrolling: touch;  */
      box-shadow: 0 2px 6px #777;
    }

    .drawer-right .drawer-wrapper {
      right: 0;
      left: auto;
      -webkit-transform: translate3d(100%, 0, 0);
      transform: translate3d(100%, 0, 0);
      width: 350px;
      max-width:90%;
    }

    .drawer-left .drawer-wrapper {
      left: 0;
      right: auto;
      -webkit-transform: translate3d(-100%, 0, 0);
      transform: translate3d(-100%, 0, 0);
      width: 350px;
      max-width:90%;
    }

    .drawer-bottom .drawer-wrapper {
      bottom: 0;
      top: auto;
      -webkit-transform: translateY(100%);
      transform: translateY(100%);
      width: 100%;
      max-height: 350px;
    }

    .drawer.is-active {
      display: block;
    }

    .drawer.is-visible .drawer-wrapper {
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
    }

    .drawer.is-visible .drawer-overlay {
      opacity: 0.5;
    }
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <script src="https://use.fontawesome.com/releases/v5.15.3/js/all.js" crossorigin="anonymous"></script>
  <title>MODAL CARDS</title>
</head>

<body>

    <a href="#" data-drawer-trigger aria-controls="slide-from-left" aria-expanded="false">Left Drawer</a>


  <div class="plans-modal">


    <section class="drawer drawer-left" id="slide-from-left" data-drawer-target>
      <div class="drawer-overlay" data-drawer-close tabindex="-1"></div>
      <div class="drawer-wrapper">
        <div class="modal-content">

          <div class="modal-header">
            <p class="modal-logo-title">
              <img src="web.png"> Web Development 
            </p>
          </div>
          
          <div class="modal-body">

            <div class="plan-card-1">
              <p class="card-title">Static Website</p>
              <hr class="card-hr">
              <span class="card-items">
                <ul class="card-li">
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                </ul>
              </span>
              <hr class="card-hr">
              <p class="plan-price"><i class="fas fa-rupee-sign"></i> 4,999/-</p>
            </div>
            
            <div class="plan-card-1">
              <p class="card-title">Static Website</p>
              <hr class="card-hr">
              <span class="card-items">
                <ul class="card-li">
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                  <li><i class="fas fa-arrow-circle-right"></i> Category: Static Website</li>
                </ul>
              </span>
              <hr class="card-hr">
              <p class="plan-price"><i class="fas fa-rupee-sign"></i> 4,999/-</p>
            </div>

          </div>
          
          <div class="modal-footer">
            <span class="plans-btns">
              <i class="fas fa-chevron-circle-up" id="btnUp"></i>
              <i class="fas fa-chevron-circle-down" id="btnDown"></i>
            </span>
            <button class="close-btn" data-drawer-close>Close</button>
          </div>

        </div>
      </div>
    </section>

  </div>

event listener when selecting an option from select tag dynamically

I’m selecting an option from select tag in javascript by:

let btnH = document.querySelector('#btn_heads')
btnH.querySelector('[value="{{ $btn_heads }}"]').selected = true;

and the select tag has change listener:

btnH.addEventListener('change', s);

but it isn’t wokring.

you can edit this snippet (I want an alert saying “selected : 7” without selecting it manually):

let i = document.querySelector('#i');

i.querySelector('[value="7"]').selected = true;

i.addEventListener('change', e=>{
  alert('selected : '+e.target.value);
});
<select id="i">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>

Compare two arrays in react and filter one based on matches of name property

I’m trying to filter a players array by comparing the names property to a roster array and rendering the matches from the players array.

When a user selects a year the getCollegeRoster() function returns players who have a year property matching the selection. From there I’m trying to filter and display the .name matches from the players array, but it seems i’m unable to update playerStateValue. I’m using recoil to manage state. Any insight would be much appreciated.

    setSelection(newSelection);
    console.log('newselect', newSelection)
    getCollegeRoster();
    const filteredArray = [...playerStateValue.players].filter((el) => ({
      name: el.name,
      match: [...roster].some((f) => f.name === el.name)
      })
    );
      setPlayerStateValue((prev) => ({
        ...prev,
        players: filteredArray as Player[],
        playersCache: {
          ...prev.playersCache,
          [communityData?.id!]: filteredArray as Player[],
        },
        playerUpdateRequired: false,
      }));
   } ```  

How to display 2 lines with ellipsis at the end with css in react js?

I want to display post description in 2 lines with ellipsis at the end . I actually copied the styles needed from inspecting youtube css styles . Youtube styles work on all browsers like safari and iOS devices browsers .

enter image description here

enter image description here

and I use inline styling in react js like this :

                       <span
                          style={{
                            lineHeight: "2rem",
                            fontWeight: "500",
                            maxHeight: "4rem",
                            overflow: "hidden",
                            display: "-webkit-box",
                            textOverflow: "ellipsis",
                            whiteSpace: "normal",
                            WebkitLineClamp: 2,
                            WebkitBoxOrient: "vertical",
                            msTextOverflow: "ellipsis",
                          }}
                        >
                          {description}
                        </span>

The problem is it doesn’t on macbook safari browser or any iOS device browser but it is the same css styles that youtube has .

How can I make sure that these styles work on iOS devices browsers and safari ? Is there something missing ?

Find max value in a Javascript Object and print all values [duplicate]

I apologize but I am very new to JavaScript. I have a toy object derived from two arrays. What I want to do is find the largest value of the make parameter (i.e., make = 3) and get an object that has all the parameters (i.e., make and model ) of make equal to 3

const arr1 = [1, 2, 3];
const arr2 = ['a', 'b', 'c'];
const myArr = [];

for(i = 0; i < arr1.length; i++){
    var myCar = new Object();
    myCar.make = arr1[i];
    myCar.model = arr2[i];
    myArr.push(myCar)
}
console.log(myArr);
>>> [ { make: 1, model: 'a' },
  { make: 2, model: 'b' },
  { make: 3, model: 'c' } ]
var mm = Math.max(...myArr.map(o => o.make))
console.log(mm)
>>> 3

I wish {make: 3, model: 'c'}

Access to XMLHttpRequest … has been blocked by CORS policy:

I’m gettting this error on a project Access to XMLHttpRequest at ‘https://project3.herokuapp.com/Register’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

I’m not sure what it means. My app stopped working a couple of days ago and started showing this error.

Convert jQuery .html to vanilla js

I am converting a project away from jQuery and I thought this would be trivial…How do I convert:

let tb = $("#design_table tbody");
tb.html("");

I tried:

let tb = document.querySelector("#design_table tbody");
tb.innerHTML = "";
  

Promise: difference of await vs. just calling the function

I am trying to understand async/await and understanding the difference of await vs. just calling the function as-is, would be synchronous anyways, right?

function foo() {
     this.doSomething(); // waits for this to run before going to next line
     return "1";
}

async foo() {
     await this.doSomething(); // waits for this to run before going to next line
     return "1";
}

aren’t they both waiting for doSomething() to finish?

Returning time in specific timeZone and format

I am just get started in programming, and I have a question about time. The system I am working on is set in UTC time. However, I need to return a result in US Central time ‘Chicago/Americas’ in a specific format YYYY-MM-DD-hh:mm:ss. I’ve gone down the rabbit hole on the various methods of doing this, but none seems to have exactly what I am looking for and frankly I am more confused than when I started.

The closest I’ve been able to get to this is this, using toLocaleString in conjunction with toISOString.

var now = new Date(new Date().toLocaleString(“en-US”, {timeZone: “America/Chicago”})); // returns correct Timezone, but incorrect format

var StatusTime = now.toISOString(); //returns partially correct format.

The output from this is in the correct timezone, but the formatting is not quite right, e.g. ‘2022-07-15T12:01:57.000Z’. This response includes the Zulu time indicator, which is incorrect. There has got to be an easier way to accomplish this. Any advice would be appreciated. Thank you in advance.

Verify if this line of codes are correct

function sumOfNumbers(arrayOfNumbers) {
  let arrayOfNumbers = [1, 2, 3, 4, 5, 6, 7]
  const arrayLength = arrayOfNumbers.length;
  let sum = 0;
  for (i = 0; i <= arrayLength; i++) {
    sum = sum + arrayLength[i];
  }
  /*console.log(sumOfNumbers(sum))*/
  return (sumOfNumbers(sum));
}

I used console.log nothing came up, I will appreciate if I am corrected.

UI not showing the updated data

I have a widget(JavaScript &Html) that displays multiple user names along with Radio button selection for each user in Edit page. After selecting the radio button for each user, the continue button click will direct to a Summary page where User name will be displayed along the value of radio button option selected in previous page. My code is fine and it works well but unusually in rare cases I’m getting the Summary page displaying a wrong value of radio button selected in previous page. This happens especially when I go back to the edit page from Summary page, change the previously selected value and return back to summary page. The Summary page should display the newly selected value but it’s displaying the old value. This issue is not consistent it occurs only for some cases. It’s a Javascript code. Has anyone faced this issue?

Problem with an external redirection on a react application

So the problem I have is that I want to create a button that redirects me to a page external to my app in react. I have worked with the react router before, the problem is that this time, the code I have is from an external, I am updating it and I need to understand how to redirect to an external page

Here’s an example of how they generate the routes

title: "Admin",
  screens: [
    {
      name: "Inicio",
      url: "/dashboard/inicio",
      icon: <DashboardOutlinedIcon />,
      component: Home,
    },

Something I tried was; create an attribute similar to this, replacing the redirect with an external one, like so:

{
  name: "External redirection",
  url: "https://fake-url.com",
  icon: <CallIcon />,
},

But at the time of testing it, clicking on the button only adds the link that I put, along with the url that it already has, that is:

Image of the problem

So that’s the problem, i will appreciate any kind of help 🙁

React native status bar text color doesn’t change on Android 12

I’m trying to change status bar text color and background color. Background color changes with no issue but the text color is not changing only on Android 12. I tried to change as JSX but that doesn’t work too. Is there any other way to do it?

I’m using built-in StatusBar.

useEffect(() => {
  if (darkMode) {
    StatusBar.setBackgroundColor("#101010", true); 
    StatusBar.setBarStyle("light-content", true)
  } else {
    StatusBar.setBackgroundColor("white", true); 
    StatusBar.setBarStyle("dark-content", true)
  }
}, [darkMode])

So I’m trying to workout my app so that the user can log into it by using google account

So I’m trying to workout my app so that the user can log into it by using google account.
I’m using sanity and the login button works and the data is being written in the sanity database. However I’m not sure that the app is fetching the data from the database properly.
Considering after the user logs in to the app the user is redirected to homepage where there is supposed to show the users google profile picture.
This is ReactJS with tailwindcss and sanity.
Here is my code..

Login component:

import React from 'react'
import { useNavigate } from 'react-router-dom';
import { GoogleLogin } from '@react-oauth/google';
import jwt_decode from 'jwt-decode';

import Logo from '../Assets/Logo/Logo1.png'
import { client } from '../client'

import img1 from '../Assets/LoginPage/1.jpg';
import img2 from '../Assets/LoginPage/2.jpeg';
import img3 from '../Assets/LoginPage/3.jpeg';
import img4 from '../Assets/LoginPage/4.jpg';
import img5 from '../Assets/LoginPage/5.jpg';
import img6 from '../Assets/LoginPage/6.jpeg';
import img7 from '../Assets/LoginPage/7.jpeg';
import img8 from '../Assets/LoginPage/8.jpeg';
import img9 from '../Assets/LoginPage/9.jpg';

const Login = () => {
  const navigate = useNavigate();
  const responseGoogle = async (response) => {
    const decoded = { name:String, picture:String, sub:String } = jwt_decode(response.credential);
    const { name, picture, sub } = decoded;
    const user = {
      _id: sub,
      _type: 'user',
      userName: name,
      image: picture,
    }

    client.createIfNotExists(user)
      .then(() => {
        navigate('/', {replace: true})
      })

    // console.log(decoded)
  };

  return (
    <div className='bg-gray-800 h-screen justify-start' >
      <div className='md:fixed md:grid md:grid-cols-3 md:gap-0 flex flex-col'>
        <div className=''>
            <img src={img1} alt="image 1" />
        </div>
        <div className=''>
          <img src={img2} alt="image 2" />
        </div>
        <div className=''>
          <img src={img5} alt="image 5" />
        </div>
        <div className=''>
          <img src={img6} alt="image 6" />
        </div>
        <div className='-mt-[5vh]'>
          <img src={img4} alt="image 4" />
        </div>
        <div className='md:mt-[2.5vh]'>
          <img src={img8} alt="image 9" />
        </div>
      </div>
      <div className='absolute flex flex-col justify-center items-center top-0 bottom-0 left-0 right-0 bg-blackOverlay'>
        <div className='fixed px-[5em] py-[4em] bg-gray-700 border-4 border-mainColor rounded-xl justify-center'>
          <div className='flex justify-center items-center -mt-[4em]'>
            <div className='p-1 my-2 bg-gray-500 rounded-[75%]'>
              <img src={Logo} width="60px" alt="Logo" />
            </div>
            <div className='text-[2em] ml-[5px] font-[Fredoka_One, cursive]'>
              <h1><span className='text-white'>Share</span><span className='text-gray-400'>Smile</span></h1>
            </div>
          </div>
          <div className='flex justify-center mt-[8em] scale-150'>
            <GoogleLogin 
              onSuccess={(response) => responseGoogle(response)}
              onError={() => console.log('error')}
            />
          </div>
        </div>
      </div>
    </div>
  );
};
export default Login

Home container:

import React, { useState, useRef, useEffect } from 'react'
import { GoogleOAuthProvider } from '@react-oauth/google'
import { HiMenu } from 'react-icons/hi'
import { AiFillCloseCircle } from 'react-icons/ai'
import { Link, Route, Routes } from 'react-router-dom'

import { Sidebar, UserProfile } from '../components'
import Pins from './Pins'
import { userQuery } from '../utils/data'
import { client } from '../client'
import Logo from '../Assets/Logo/Logo1.png'

const Home = () => {
  const [toggleSidebar, setToggleSidebar] = useState(false);
  const [user, setUser] = useState(null)
  const userInfo = localStorage.getItem('user') !== 'undefined' ? JSON.parse(localStorage.getItem('user')) : localStorage.clear();

  useEffect(() => {
    const query = userQuery(userInfo?.googleId);

    client.fetch(query)
      .then((data) => {
        setUser(data[0]);
      })
  }, [])
  

  return (
      <div className='flex bg-gray-700 md:flex-row flex-col h-screen transition-height duration-75 ease-out'>
        <div className='hidden md:flex h-screen flex-initial'>
          <Sidebar />
        </div>
        <div className='flex md:hidden flex-row'>
          <HiMenu fontSize={40} className='cursor-pointer' onClick={() => setToggleSidebar(false)}/>
          <Link to="/">
            <img src={Logo} alt="Logo" className='w-10 p-0.5 bg-gray-500 rounded-[75%]' />
          </Link>
          <Link to={`user-profile/${user?._id}`}>
            <img src={user?.image} alt="Profile" className='w-10' />
          </Link>
        </div>
      </div>
  )
}

export default Home

data.js utility:

export const userQuery = (userId) => {
    const query = `*[_type == "user" && _id == '${userId}']`;
    return query;
}

and this is App.js

import {React, useEffect} from 'react'
import { Routes, Route, useNavigate} from 'react-router-dom';
import { GoogleOAuthProvider } from '@react-oauth/google';

import Login from './components/Login';
import Home from './container/Home';

const App = () => {
  const navigate = useNavigate();

  useEffect(() => {
    const User = localStorage.getItem('user') !== 'undefined' ? JSON.parse(localStorage.getItem('user')) : localStorage.clear();

    if (!User) navigate('/Login');
  }, []);

  return (
    <GoogleOAuthProvider clientId={`${process.env.REACT_APP_GOOGLE_API_TOKEN}`}>
      <Routes>
        <Route path="login" element={<Login />} />
        <Route path="/*" element={<Home />} />
      </Routes>
    </GoogleOAuthProvider>
  )
}

export default App

Anyone knows what is wrong here?
I’m going after tutorial on social media app by JavaScriptMastery on youtube.
And considering google changed it’s login authentication I had to go to another video that he covered that but translate a part of the code from typescript to javascript.