Getting Error of PODS while creating new react native project on windows

Im windows user, my previous and existing projects are running smoothly I’m getting this error while craeting new project im also unable to craete/run android file/projects even if i ignore pods

Welcome to React Native 0.75.0!
Learn once, write anywhere
x Downloading template
error Installing pods failed. This doesn’t affect project initialization and you can safely proceed.
However, you will need to install pods manually when running ios, follow additional steps in “Run instructions for ios”
section.
Run instructions for Android:
• Have an Android emulator running (quickest way to get started), or a device connected.
⚫ cd “C:UsersrazarRN Projectsloginscreens” && npx react-native run-android
Run instructions for Windows:
• See https://aka.ms/ReactNativeGuideWindows for the latest up-to-date instructions.

tried chatgpt
uninstalled/installed -g @react-native-community/cli
npm cache clean –force

Checking if object already exists in another array before adding it

I have an array of objects (opciones) and another array (visibles) where im trying to add the objects that are supposed to show up.

 function next(ev, next) {
    ev.preventDefault();
    setToggle(next.siguiente);
    let element = document.getElementById(next.siguiente);
    opciones.map(
      (opcion) => opcion.id === next.siguiente && visibles.push(opcion)
    );
  }

Next is the current object i’m passing onClick/submit.
SetToggle: i set visibility of the component i want to show.
next.siguiente – the next component ID that has to show up after this function is finished.
opciones – my initial array of objects
**visibles **- the array where i add the selected objects
and in my opciones.map function i’m trying to detect if the next component ID exists in the opciones array i want to push it into visibles array.
It works but im obviously getting duplicates the way i’m doing it right now.

This is my opciones object for better understanding:

  const opciones = [
    {
      id: "TAB_inicio",
      texto: "Inicio",
      visibilidad: "",
      siguiente: "TAB_incluido",
      descripcionTitulo: "Bienvenido al programa de carga de Viajes",
      descripcion: "Selecciona lo que quieras hacer",
      icon: <FaCheckCircle />,
      next: next,
      contenido: <Inicio />,
      botonSiguiente: "Nuevo Viaje",
    },
    {
      id: "TAB_descripcion",
      texto: "Descripción",
      visibilidad: "hidden",
      siguiente: "TAB_prueba",
      descripcionTitulo: "Descripcion",
      descripcion: "detalles importantes",
      icon: <FaBookOpen />,
      next: next,
      contenido: <Descripcion />,
      botonSiguiente: "Siguiente",
    },
    {
      id: "TAB_incluido",
      texto: "Incluido / no",
      visibilidad: "hidden",
      siguiente: "TAB_descripcion",
      descripcionTitulo: "Incluido/ No incluido",
      descripcion:
        "Si el servicio no está seleccionado, el cliente lo verá como no incluido.",
      icon: <FaCheckDouble />,
      next: next,
      contenido: <Incluido />,
      botonSiguiente: "Siguiente",
    }
  ];

So pretty much siguiente would be the ID of the next object / component i want to display.
How would i be able to check if visibles already has the added object before i add it again?
i tried something like:

 function next(ev, next) {
    ev.preventDefault();
    setToggle(next.siguiente);
    let element = document.getElementById(next.siguiente);
    if (visibles.includes(next)) {
      console.log("already exists");
    } else {
      opciones.map(
        (opcion) => opcion.id === next.siguiente && visibles.push(opcion)
      );
    }
  }

but it doesn’t really work. I’m getting duplicated keys when displaying the list and it keeps adding to the array.
Any help or recommendation in general to improve this would be appreciated! Thank you in advance.

Firebase is not defined error when initializing firebase

I was following a tutorial and ReferenceError: firebase is not defined keeps poping up

I tried following some past question on stackOverflow but was not able to solve this. please tell me if i am doing something wrong

   <script src="https://www.gstatic.com/firebasejs/13.15.1/firebase-app.js"></script>
   <script src="https://www.gstatic.com/firebasejs/13.15.1/firebase-auth.js"></script>
   <script src="https://www.gstatic.com/firebasejs/13.15.1/firebase-firestore.js"></script>
   <script>
     // Initialize Firebase
     const firebaseConfig = {
        apiKey: "AIzaSyDdM1wifQDRC5Yx1lqiMbMXHhas_gQtgog",
        authDomain: "notes-project-e1952.firebaseapp.com",
        projectId: "notes-project-e1952",
        storageBucket: "notes-project-e1952.appspot.com",
        messagingSenderId: "730725354888",
        appId: "1:730725354888:web:b51688d6904jdvnjsb87e3d",
        measurementId: "G-4FJRM2XQW5"
        };

        // Initialize Firebase
        firebase.initializeApp(firebaseConfig);
   
        // Make auth and firestore references
        const auth = firebase.auth();
        const db = firebase.firestore();
   </script>
   
  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
  <script src="scripts/auth.js"></script>
  <script src="scripts/index.js"></script>

It is posible detect when recaptcha v2 image challange showed?

I have this file to show rectapcha v2 and I need to detect that recaptcha show image challange. This html is displayed in flutter application and I need that capture to enlarge the webview where the recaptcha is displayed


    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
    <script>
    
        function onLoad() {

          grecaptcha.render('recaptcha', {
            'sitekey': '<KEY>', 
            'callback': onSuccess,        
            'expired-callback': onExpired, 
            'error-callback': onError      
          });
        }
  
    function onSuccess(token) {
        alert('Verification successful!');
            if (window.Captcha) {
                window.Captcha.postMessage('success');
            }
       
    }

    function onExpired() {
        console.log("reCAPTCHA expired");
        if (window.Captcha) {
          window.Captcha.postMessage("expired");
        }
    }

    function onError() {
        console.log("reCAPTCHA error or challenge");
        if (window.Captcha) {
          window.Captcha.postMessage("error");
        }
    }

    function onChallangeOpen() {
        if (window.Captcha) {
          window.Captcha.postMessage("challenge");
        }
    }
    </script>

Errors in fetching Data on MongoDB

Hello ive been having an issue with my webApp . My homepage cant fetch data from the backend . ive have a js file at the backend name studentRecords that populate details from the data models but when i try login with my admission number . The response is that it has fail to fetch the student records. Any assistance in this will be highly appreciated .[This is my home componentHere is my studentRecords.js](https://i.sstatic.net/4hvTx6GL.png)

Home page I tried debugging the studentRecords.js file but ive not been able to solve the issue . And what i expected is that after i logged in with my admission number at the login page , I’m able to see the student records at the home component . But it has hasn’t work.

clone array of jquery/html elements

I have to clone some table rows. I only can select this rows based on their indexes. I can’t use any common class or attribute to select the rows in one shot.

I do this like this:

const rows: JQuery<HTMLElement>[] = [];
      for (let i = 0; i <= rowIndexes!.length - 1; i++) {
        const row = $(
          `tr[ng-reflect-data-row-index='${rowIndexes![i]}'`
        );
        rows.push(row);
      }

And after this I want to clone the rows array like this:

$(rows).clone()

But with this I get the error TypeError: e.cloneNode is not a function.

So, the question is, how can I clone this array as a jquery element? After clone I want to do some other operations on it, f.e. animate, wrapAll.

Thanks.

Firefox vs Chrome JavaScript URL validaion with `new URL()`

I’m trying to validate URL’s in JavaScript and according to MDN JavaScript’s URL API is compatible with Chromium browsers and Firefox. However the behaviour varies between the two browsers. Specifically it seems like Chromium browsers are far more lenient and automatically apply encoding and Firefox doesn’t.

I’ve tried encoding the URL myself first before validating with encodeURI('https://abc.co m'), but Firefox also doesn’t accept https://abc.c%20m as a valid URL, so I’m stumped as to how I can have a good way to support both browsers without having to resort to regex.

Any ideas for a consistent approach with cross browser support are very welcome. Thanks!

enter image description here

Scroll Getting Stuck When Changing Between The child components

import { useEffect, useState } from 'react';
import styles from './Styles.module.scss';
import Loader from '../../components/Loader/Loader';
import ScrolledBar from '../../components/ProgressBar/ProgressBar';
import MainSection from '../../components/MainSection/MainSection';
import MouseIcon from '../../components/MouseIcon/MouseIcon';

import { ReactIcon } from '../../components/svgs';
import { threshold } from 'three/webgpu';

const Home = () => {
  
  const [load, setLoad] = useState(true);
  const [snapScroll, setSnapScroll] = useState(false);
  const [blur, setBlur] = useState(false);

  const skills = [
    { skillName: 'React JS', skillImage: ReactIcon, skillLevel: 80, description: "" },
    { skillName: 'React Native', skillImage: ReactIcon, skillLevel: 70, description: "" },
    { skillName: 'Node JS', skillImage: ReactIcon, skillLevel: 60, description: "" },
    { skillName: 'Express JS', skillImage: ReactIcon, skillLevel: 60, description: "" },
    { skillName: 'Javascript', skillImage: ReactIcon, skillLevel: 89, description: "" },
    { skillName: 'Java', skillImage: ReactIcon, skillLevel: 56, description: "" },
    { skillName: 'Spring Boot', skillImage: ReactIcon, skillLevel: 70, description: "" },
    { skillName: 'Microserivces', skillImage: ReactIcon, skillLevel: 66, description: "" },
  ]

  useEffect(() => { 
    if(load) return;

    const snapSection = document.getElementById("SnapSection")!;

    const observer = new IntersectionObserver((entries) => {
      entries.map((entry) => {
        setSnapScroll(entry.intersectionRatio == 1);
        setBlur(entry.intersectionRatio > 0.1);
      });
    }, {threshold: [.1, 1]});

    observer.observe(snapSection);

    return () => observer.disconnect();
  }, [load]);

  useEffect(() => {
    if(load) {
      setTimeout(() => setLoad(false), 2000);
      return;
    }
    
    const maximumScrollLength = document.getElementsByTagName('main')[0].clientHeight;
    console.log(maximumScrollLength);

    const observer = new IntersectionObserver((entries) => {
      entries.map((entry) => {
        if(entry.isIntersecting) {
          entry.target.classList.add(styles.animateProgBar);
        } else {
          entry.target.classList.remove(styles.animateProgBar);
        }
      })
    })

    const progressBars = document.querySelectorAll(".progressBar");
    progressBars.forEach((a) => observer.observe(a));

  }, [load]);

  return load ? (<Loader />) : (
    <main className={`${styles.main}`}>
      <article>
        <MouseIcon />
        <ScrolledBar />
        <div className={`${styles.backEffect}`} ></div>
      </article>
      <article className='overscroll-auto'>
        <MainSection />
        <section id="SkillSection" className={`min-h-[100vh] flex flex-col gap-5 overscroll-auto justify-center items-center py-11 sticky top-0 transition-all ${blur && 'filter blur-sm' }`}>
          <div className='grid gap-3 w-[60%]'>
            { skills.sort((a, b) => b.skillLevel - a.skillLevel).map((a, i) => (
              <div className='flex flex-col gap-2' key={i}>
                <h1 className='font-iceberg text-3xl' >{a.skillName}</h1>
                <div className={`h-[10px] bg-yellow-300 rounded-lg relative`}>
                  <div className={`bg-red-500 h-[100%] overflow-visible rounded-lg flex justify-end items-center progressBar ${styles.progressBar}`} style={{ width: a.skillLevel+"%" }}>
                    <div className='w-6 aspect-square border p-1 rounded-lg' style={{ background: "var(--background-color)", borderColor: "var(--text-color)" }}>
                      {a.skillImage()}
                    </div>
                  </div>
                </div>
              </div>
            ))}
          </div>
        </section> 
        <article id='SnapSection' className={`relative z-20 h-[100vh] overflow-hidden overscroll-auto  ${snapScroll && 'overflow-scroll snap-y snap-mandatory'}`}>
          <section className='p-10 w-[100%] h-[100vh] bg-red-400 snap-start'>Dev Garg</section>
          <section className='p-10 w-[100%] h-[100vh] bg-yellow-400 snap-start'>Dev Garg</section>
        </article>
            </article>
        </main>
    )
}

export default Home;

So I was Writing The Above Code in Which I have an Article which contains 3 different components MainSection, **SkillSection **and SnapSection. I wanted the main and SkillSection to scroll Normally then i wanted the Snap Section to appear and start Snaping the inner childs. I have somehow implemented the above said action but for some reason my scroll get stuck when shifting between the components i.e. SkillSection and SnapSection. I cant understand the reason. When snapSection is completly on the screen the scroll gets stuck and doesnt work until the mouse is moved.

For above feilds to not get Stuck i used various things like overscroll-behavious: auto. IntersectionObserver, etc but i can’t seem to make it work. The scroll works properly initially but after some time it start causing problem (Stuck) again. I am activating snap-scroll only when the snapSection is completely loaded. But till i move my mouse slightly it doesnt switch the scroll between child components.

Also, Please help if there is any other better method to implement this functionality.

Custom context menu with fade transition in JavaScript

I’ve been trying to create a custom context menu with some buttons in it, however there is a problem. I have an opacity transition, and it only runs once when I right click. The next times I right click the menu will show up but without the opacity transition.

Here is my code:
HTML:

<div id="contextMenuDesktop">
    <ul>
        <!-- Some elements here -->
    </ul>
</div>

JavaScript:

document.addEventListener('contextmenu', function(e) {
    event.preventDefault();
    if(!menuOpened) {
        document.getElementById("contextMenuDesktop").style.opacity = "0";
        setInterval(function() {
                document.getElementById("contextMenuDesktop").style.opacity = "1";
        }, 100); // It has to be run few milliseconds after, for some reason
        document.getElementById("contextMenuDesktop").style.display = "block";
        document.getElementById("contextMenuDesktop").style.left = `${e.pageX}px`;
        document.getElementById("contextMenuDesktop").style.top = `${e.pageY}px`;
}});

CSS:

#contextMenuDesktop {
    transition: opacity 500ms;
    opacity: 0;
    height: 375px;
    width: 175px;
    background-color: rgba(100,100,100,.6);
    color: white;
    border-radius: 10px;
    box-shadow: 7px 7px 3px lightgray;
    backdrop-filter: blur(5px);
    position: fixed;
    z-index: 3;
    display: none;
    
}

I believe the problem is that the line that sets the opacity to 0 doesn’t have time to finish, and after only 100 milliseconds it has to be visible again, so the transition doesn’t work. Does somebody know the answer?

unable to get user object from session and req.isAuthenticated() is false after Oauth Google login

Create a login application using the frontend using React, the backend using Express, and the passport GoogleOauth 2.0.
Google auth allows for login, however the req.user is not saved in the system. Following the initial login, the req.isAuthenticated is likewise false. Here is my code for the auth/google/callback and the session. Please point out the mistakes I’m doing to me.

 const express = require("express");
const helmet = require("helmet");
const cors = require("cors");

const passport = require("passport");
// const AuthuRouter = require("./src/routes/user/auth.router");
const StoreRouter = require("./src/routes/store/store.router");

const mongoose = require("mongoose");
const session = require("express-session");
const rateLimit = require("express-rate-limit");

const GoogleStrategy = require("passport-google-oauth20").Strategy;
// const passport = require("./src/configs/passport");
const { isAuthorized, isAuthenticat } = require("./src/middleware/auth");
const User = require("./src/routes/user/user.model");
require("dotenv").config();

const app = express();
app.use(helmet()); 


app.use(
  cors({
    origin: "http://localhost:5173", 
    credentials: true,
  })
);
app.use(express.json()); /

app.use(
  session({
    secret: process.env.COOKIE_KEY, 
    resave: false,
    saveUninitialized: false,
    cookie: {
      secure: false, 
      maxAge: 24 * 60 * 60 * 1000,
      sameSite: "None", 
    },
  })
);
// Passport initialization
app.use(passport.initialize());
app.use(passport.session());
app.use((req, res, next) => {
  console.log("middle ware");
  next();
});
// Rate limiting
const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100, // limit each IP to 100 requests per windowMs
});
// Applying rate limiting to all routes
app.use(limiter);

passport.use(
  new GoogleStrategy(
    {
      clientID: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      callbackURL: "/auth/google/callback",
    },
    async (token, tokenSecret, profile, done) => {
      try {
        // Check if user already exists in database
        let user = await User.findOne({
          email: profile.emails[0].value,
        }).select("email accessRights name _id");
        // console.log(user);
        if (!user) {
          return done(null, false, {
            message:
              "Email not registered. Please use a registered email or sign up.",
          });
        }

        return done(null, user);
      } catch (err) {
        return done(err, null);
      }
    }
  )
);

// Serialize user into the sessions
passport.serializeUser((user, done) => {
  done(null, user._id); // Store only the user ID in the session
});

// Deserialize user from the sessions
passport.deserializeUser(async (id, done) => {
  try {
    const user = await User.findById(id).select("email accessRights name _id");

    done(null, user); // Attach the user object to req.user
  } catch (err) {
    done(err, null);
  }
});

// Session setup

// MongoDB connection
mongoose.connect(process.env.MONGO_URI);

// Routes
// Session status route
app.get(
  "/signin",
  passport.authenticate("google", {
    scope: ["email"],
  })
);

// Google OAuth callback
app.get(
  "/auth/google/callback",
  passport.authenticate("google", {
    failureRedirect: "/auth/signin",
  }),
  (req, res) => {
    console.log("callback");
    // console.log(req.user);

    if (req.user) {
      req.session.user = req.user;
      req.session.regenerate(function (err) {
        if (err) next(err);

        req.session.user = req.user;

        req.session.save(function (err) {
          console.log(req.isAuthenticated());
          if (err) return next(err);
          return res.redirect(`http://localhost:5173/dashboard`);
        });
      });

      // res.json({ user: req.user });
      // res.redirect(`http://localhost:5173/dashboard`);
    } else {
      res.status(401).json({ message: "No user logged in" });
    }
  }
);

// Logout
// Logout
app.get("/logout", (req, res) => {
  req.session.user = null;

  req.logout((err) => {
    if (err) {
      // Handle error if logout fails
      return res.status(500).json({ message: "Logout failed" });
    }
    req.session.destroy((err) => {
      if (err) {
        // Handle error if session destruction fails
        return res.status(500).json({ message: "Failed to destroy session" });
      }
      res.clearCookie("connect.sid"); // This is the default cookie name for express-session
      res.save.regenerate(function (err) {
        if (err) next(err);
        res.redirect("/auth/signin?message=Logged out successfully");
      });
      res.redirect("/auth/signin?message=Logged out successfully");
    });
  });
});

I am getting some typescript error in my Class component. when exporting in HOC component

Below is my HomePage Class Component. I am getting some typescript error.

   import * as React from "react";
    import { Dispatch, AnyAction } from 'redux';
    import { connect } from 'react-redux';
    import { Link, RouteComponentProps } from 'react-router-dom';
    import isEqual from "lodash/isEqual";
    import "./HomePage.scss";
    import "../assets/styles.scss";
    import { resourceTypeEnum } from '../config/constants';
    import ResourceStocks from "./ResourceStocks";
    import SimcardStocks from "./SimcardStocks";
    import MsisdnStocks from "./MsisdnStocks";
    import DeviceStocks from './DeviceStocks';
    import { ConsulState } from "../consul/consul.types";
    import { consulInit } from "../consul/consul.data";
    import { HomePageActions, resourceStocksDataType, stocksFilterValuesType, lifecycleStatusesTypes, stocksDetailsTypes, resourceFilterValuesTypes, searchableFieldValuesTypes } from './HomePage.actions';
    import { AppState } from '../store';
    const classnames = require("classnames");
    
    interface HomePageStateProps {
        activeResourceType?: string;
    }
    
    interface HomePageProps {
        resourceStocks: resourceStocksDataType,
        stocksFilterValues: stocksFilterValuesType,
        lifecycleStatuses: lifecycleStatusesTypes,
        stocksDetails: stocksDetailsTypes;
        resourceFilterValues: resourceFilterValuesTypes;
        searchableFieldFilterValues: searchableFieldValuesTypes;
        isLoading: boolean;
        match: {
            params: {
                resourceType: string,
                stockId: string
            }
        };
        history: RouteComponentProps["history"];
        consulDetails: ConsulState
    }
    interface HomePageActionProps {
        actions: {
            getResourceStocks: (resourceType: string, stockID: string, stockName: string, SKU: string, currentPage: string) => void;
            getStocksFilterValues: (resourceType: string) => void,
            getLifecycleStatus: (resourceType: string) => void,
            getResourceFilterValues: (resourceType: string, stockID: string) => void,
            getSearchableFieldVFilterValues: (resourceType: string) => void,
        }
    }
    
    type Props = HomePageStateProps & HomePageActionProps & HomePageProps;
    class HomePage extends React.Component<Props, HomePageStateProps> {
        constructor(props: Props, context: any) {
            super(props, context);
            this.state = {
                activeResourceType: this.props.match && this.props.match.params && this.props.match.params.resourceType ? this.props.match.params.resourceType : 'sim-cards',
            };
        }
    
        handleOnCickResourceType = (resourceType: string) => {
            this.setState({
                activeResourceType: resourceType,
            });
            this.props.history && this.props.history.push(`/home/${resourceType}`)
            
        };
    
        static getDerivedStateFromProps(nextProps: Props, prevState: HomePageStateProps) {
            const { match : { params : { resourceType } } = { params : { resourceType: resourceTypeEnum.SIM_CARDS }} } = nextProps;
            if (!isEqual(resourceType, prevState.activeResourceType)) {
                return { ...prevState, activeResourceType:  resourceType }
            }
        }
    
        getStocksAndFilterValues = (resourceType: string) => {
            this.props.actions.getResourceStocks(resourceType,'All', 'All', 'All', '');
            this.props.actions.getStocksFilterValues(resourceType);
        }
    
        getStockDetailsPageData = (resourceType: string, stockId: string) => {
            this.props.actions.getLifecycleStatus(resourceType);
            this.props.actions.getResourceFilterValues(resourceType, stockId);
            this.props.actions.getSearchableFieldVFilterValues(resourceType);
        }
        
        fetchResourceStocks = () => {
            this.props.actions.getResourceStocks(this.state.activeResourceType,'All', 'All', 'All', '')
        }
        render() {
            const { consulDetails: { details } = { details: consulInit }, match: { params : { stockId }} = { params: { stockId: ""}} } = this.props;
            return (
                <React.Fragment>
                    <div className="w-app-body" id="w-app-body">
                        <nav className="w-nav-secondary">
                            <ul>
                                {
                                    details.resourceStockAndSearchConfig && details.resourceStockAndSearchConfig.enableSimCards && details.resourceStockAndSearchConfig.enableSimCards &&
                                    <li
                                        className={classnames({
                                            active:
                                                resourceTypeEnum.SIM_CARDS === this.state.activeResourceType,
                                        })}
                                    >
                                        <a
                                            href="javascript:;"
                                            onClick={() =>
                                                this.handleOnCickResourceType(
                                                    resourceTypeEnum.SIM_CARDS
                                                )
                                            }
                                            id='sim-cards-tab-in-resource-tab'
                                        >
                                            SIM Cards
                                    </a>
                                    </li>
                                }
                                {
                                    details.resourceStockAndSearchConfig && details.resourceStockAndSearchConfig.enableMsisdns && details.resourceStockAndSearchConfig.enableMsisdns &&
                                    <li
                                        className={classnames({
                                            active:
                                                resourceTypeEnum.MSISDNS === this.state.activeResourceType,
                                        })}
                                    >
                                        <a
                                            href="javascript:;"
                                            onClick={() =>
                                                this.handleOnCickResourceType(
                                                    resourceTypeEnum.MSISDNS
                                                )
                                            }
                                            id='Msisdns-tab-in-resource-tab'
                                        >
                                            MSISDNs
                                    </a>
                                    </li>
                                }
                                {
                                    details.resourceStockAndSearchConfig && details.resourceStockAndSearchConfig.enableDevices && details.resourceStockAndSearchConfig.enableDevices && 
                                    <li
                                        className={classnames({
                                            active:
                                                resourceTypeEnum.DEVICES === this.state.activeResourceType,
                                        })}
                                    >
                                        <a
                                            href="javascript:;"
                                            onClick={() =>
                                                this.handleOnCickResourceType(
                                                    resourceTypeEnum.DEVICES
                                                )
                                            }
                                            id='Devices-tab-in-resource-tab'
                                        >
                                            Devices
                                    </a>
                                    </li>
                                }
                            </ul>
                        </nav>
                        {/* <ResourceStocks
                            getStocksAndFilterValues={(resourceType: string) => this.getStocksAndFilterValues(resourceType)}
    
                            getStockDetailsPageData={(resourceType: string, stockId: string) => this.getStockDetailsPageData(resourceType, stockId)}
                            stockIdIfAvailable={this.props.match.params.stockId}
                            stockDetailsIfAvailable={this.props.selectedStockDetails}
                            setSelectedStockDetails={(stockDetails: object) => this.props.actions.setSelectedStockDetails(stockDetails)}
                            history={this.props.history}
    
    
                            resourceStocks={this.props.resourceStocks}
                            stocksFilterValues={this.props.stocksFilterValues}
                            lifecycleStatuses={this.props.lifecycleStatuses}
                            resourceFilterValues={this.props.resourceFilterValues}
                            searchableFieldFilterValues={this.props.searchableFieldFilterValues}
    
    
                            activeResourceType={this.state.activeResourceType}
                            stocksDetails={this.props.stocksDetails}
                            fetchResourceStocks={this.fetchResourceStocks}
    
                        /> */}
                        {(() => {
                            switch (this.state.activeResourceType) {
                                case resourceTypeEnum.SIM_CARDS:
                                    return <SimcardStocks 
                                        getStocksAndFilterValues = {(resourceType: string) => this.getStocksAndFilterValues(resourceType)}
                                        getStockDetailsPageData = {(resourceType: string, stockId: string) => this.getStockDetailsPageData(resourceType, stockId)}
                                        stockIdIfAvailable = {stockId}
                                        history = {this.props.history}
                                        resourceStocks = {this.props.resourceStocks}
                                        stocksFilterValues = {this.props.stocksFilterValues}
                                        lifecycleStatuses = {this.props.lifecycleStatuses}
                                        resourceFilterValues =  {this.props.resourceFilterValues}
                                        searchableFieldFilterValues = {this.props.searchableFieldFilterValues}
                                        activeResourceType = {this.state.activeResourceType}
                                        stocksDetails = {this.props.stocksDetails}
                                        fetchResourceStocks = {this.fetchResourceStocks}
                                    />;
                                case resourceTypeEnum.MSISDNS:
                                    return <MsisdnStocks 
                                        getStocksAndFilterValues = {(resourceType: string) => this.getStocksAndFilterValues(resourceType)}
                                        getStockDetailsPageData = {(resourceType: string, stockId: string) => this.getStockDetailsPageData(resourceType, stockId)}
                                        stockIdIfAvailable = {stockId}
                                        history = {this.props.history}
                                        resourceStocks = {this.props.resourceStocks}
                                        stocksFilterValues = {this.props.stocksFilterValues}
                                        lifecycleStatuses = {this.props.lifecycleStatuses}
                                        activeResourceType = {this.state.activeResourceType}
                                        stocksDetails = {this.props.stocksDetails}
                                        resourceFilterValues =  {this.props.resourceFilterValues}
                                        searchableFieldFilterValues = {this.props.searchableFieldFilterValues}
                                        fetchResourceStocks = {this.fetchResourceStocks}
                                    />;
                                case resourceTypeEnum.DEVICES:
                                    return <DeviceStocks 
                                        getStocksAndFilterValues = {(resourceType: string) => this.getStocksAndFilterValues(resourceType)}
                                        getStockDetailsPageData = {(resourceType: string, stockId: string) => this.getStockDetailsPageData(resourceType, stockId)}
                                        stockIdIfAvailable = {stockId}
                                        history = {this.props.history}
                                        resourceStocks = {this.props.resourceStocks}
                                        stocksFilterValues = {this.props.stocksFilterValues}
                                        lifecycleStatuses = {this.props.lifecycleStatuses}
                                        activeResourceType = {this.state.activeResourceType}
                                        stocksDetails = {this.props.stocksDetails}
                                        resourceFilterValues =  {this.props.resourceFilterValues}
                                        searchableFieldFilterValues = {this.props.searchableFieldFilterValues}
                                        fetchResourceStocks = {this.fetchResourceStocks}
                                    />;
                            }
                        })()}
                        <div className={classnames({"overlay": true, "show-spinner": !this.props.isLoading})}>
                            <i className="fa fa-spinner fa-pulse fa-4x"></i>
                        </div>
                    </div>
                </React.Fragment>
            );
        }
    }
    
    const mapsStateToProps = (state: AppState) => {
        return {
            resourceStocks: state.homePage.resourceStocks,
            stocksFilterValues: state.homePage.stocksFilterValues,
            lifecycleStatuses: state.homePage.lifecycleStatuses,
            stocksDetails: state.homePage.stocksDetails,
            resourceFilterValues: state.homePage.resourceFilterValues,
            searchableFieldFilterValues: state.homePage.searchableFieldFilterValues,
            isLoading: state.homePage.isLoading,
            consulDetails: state.consul,
        };
    }
    
    const mapDispatchToProps = (dispatch: Dispatch<AnyAction>): HomePageActionProps => {
        return {
            actions: {
                getResourceStocks: (resourceType: string, stockID: string, stockName: string, SKU: string, currentPage: string) => {
                    dispatch(HomePageActions.getResourceStocks(resourceType, stockID, stockName, SKU, currentPage))
                },
                getStocksFilterValues: (resourceType: string) => {
                    dispatch(HomePageActions.getStockFilterValues(resourceType));
                },
                getLifecycleStatus: (resourceType: string) => {
                    dispatch(HomePageActions.getLifecycleStatus(resourceType))
                },
                getResourceFilterValues: (resourceType: string, stockID: string) => {
                    dispatch(HomePageActions.getResourceFilterValues(resourceType, stockID))
                },
                getSearchableFieldVFilterValues: (resourceType: string) => {
                    dispatch(HomePageActions.getSearchableFieldVFilterValues(resourceType))
                },
            },
        };
    };
    
    export default connect(mapsStateToProps, mapDispatchToProps)(HomePage)

export default connect(mapsStateToProps, mapDispatchToProps)(HomePage)
i am getting error here

Argument of type ‘typeof HomePage’ is not assignable to parameter of
type ‘ComponentType’. Type ‘typeof HomePage’ is not
assignable to type ‘ComponentClass<never, any>’.
The types returned by ‘getDerivedStateFromProps(…)’ are incompatible between these types.
Type ‘{ activeResourceType: string; } | undefined’ is not assignable to type ‘Partial | null’.
Type ‘undefined’ is not assignable to type ‘Partial |

any suggestion on how to fix this error and why i am getting this error.

How to disable next month dates in current month view in React Flat Pickr with Momentjs

I’m using React Flatpickr in my project with Moment.js. In the current month’s view, dates from the next month are also shown. I want to disable these dates in the current month’s view so that users cannot select them. In React Flatpickr, these dates are disabled but still selectable. How can I prevent users from selecting these dates?

Firstly i went to Ai but not getting desire results.

Svelte 5 reactive store methods

The below code is working as it should, I’m just trying to gain a better understanding of why.

How is the getCurrentElement method of TestState reactive without the use of $derived()? Are store methods that make use of state reactive by default?

Im using [email protected]

test-store.svelte.ts

import { getContext, setContext } from 'svelte';

class TestState {
  elements = [
    {
      id: 'hghxt',
      name: 'Give',
    },
    {
      id: 'vhtl9',
      name: 'Connection',
    },
    {
      id: '5n0t0',
      name: 'Take notice',
    },
    {
      id: 'xlfba',
      name: 'Keep learning',
    },
    {
      id: '1f3z2',
      name: 'Be active',
    },
  ];

  #currentElementId = $state<string>();
  
  getCurrentElement() {
    return this.elements.find(element => element.id === this.#currentElementId);
  }

  setCurrentElement(id: string) {
    if (!this.elements.some(element => element.id === id)) return;

    this.#currentElementId = id;
  }
}

const TEST_STORE_KEY = Symbol('TEST_STORE');

export function setTestState() {
  return setContext(TEST_STORE_KEY, new TestState());
}

export function getTestState() {
  return getContext<ReturnType<typeof setTestState>>(TEST_STORE_KEY);
}

TestComponent.svelte

<script lang="ts">
  import { getTestState } from '$lib/stores/test-store.svelte';

  // initialised at +page.svelte
  const testState = getTestState();
</script>

{#each testState.elements as { name, id }}
  <button 
    class:bg-yellow={testState.getCurrentElement()?.id === id} 
    onclick={() => testState.setCurrentElement(id)}>
    {name}
  </button>
{/each}

Modifying the input triggers the listener with a value that includes the latest user input

For example, if the input is 10 and the user types 1, the detected value becomes 101, which is greater than 50. The value is then set to 50, but on the next detection, it changes to 501 instead of staying at 50.

const inputElement = document.getElementById('myInput');

inputElement.addEventListener('input', function(event) {
  let value = Number(event.target.value)
  console.log(value)
  if (value > 50) {
    event.target.value = 50
    console.log("It cannot be greater than 50");
  }
});
<input type="text" id="myInput" placeholder="Type something...">

My input is:’1′ -> ‘0’ -> ‘1’;

The output I get is:
2test.html:8 1
2test.html:8 10
test.html:8 101
test.html:11 It cannot be greater than 50
test.html:8 501
test.html:11 It cannot be greater than 50