How to use addEventListener to redirect to another html page on button click?

Advertisements How to redirect to the next page using addEventListner? Here, when I click the button it has to redirect to another HTML page how to write the code for that. HTML <button>submit</button> JS let btn = document.querySelector(‘button’) btn.addEventListener(‘click’, () => { }) >Solution : You can try this: let btn = document.querySelector(‘button’) btn.addEventListener(‘click’, ()… Read More How to use addEventListener to redirect to another html page on button click?

update state from context return error 'setState is not a function'

Advertisements Description I am creating a dark/light mode feature using context in useContext in React.JS, but I am encountering a problem. I am new to using useContext in react.js, so I am asking for help to find the problem. Problem When i set theme, it returns error. Code ModeProvider.js import React, { useState } from… Read More update state from context return error 'setState is not a function'

On first Load useEffect hock Shows an error calling the api multiple time

Advertisements I’m new to React.js On the First Time load Code shows an error when i comment this part {data.advice} and run it shows me html it also calls API 2 times it gives an Error on Reload. how to fix it? import { Box, Button, Card, CardActions, CardContent, Container, Typography } from ‘@mui/material’; import… Read More On first Load useEffect hock Shows an error calling the api multiple time

How to count elements by date month and year

Advertisements I have a function that can count the total number of occurences for elements. However, i would like to have a function that can count the elements by date, month or year. data.js [{ _id:"1", "Name":"John", "Booked":"Executive" "date": 2023-03-02T18:15:26.723+00:00 }, { _id:"2", "Name":"Peter", "Booked":"Economy", "date": 2023-03-19T19:15:26.723+00:00 }, { _id:"3", "Name":"Wade", "Booked":"Economy", "date": 2024-04-19T19:15:26.723+00:00 },… Read More How to count elements by date month and year

Nested Routing in react js. Make default component on user click

Advertisements <BrowserRouter> <Routes> <Route path=’/’ element={<Home />} /> <Route path=’users’ element={<Users />} > <Route path=’user1′ element={<User1 />} /> <Route path=’user2′ element={<User2 />} /> <Route path=’user3′ element={<User3 />} /> </Route> </Routes> </BrowserRouter> ____________________________________________ import React from ‘react’ import { NavLink, Outlet } from ‘react-router-dom’ function Users() { return ( <div> <NavLink to=’user1′>User1</NavLink> <NavLink to=’user2′>User2</NavLink> <NavLink to=’user3′>User2</NavLink>… Read More Nested Routing in react js. Make default component on user click