Category "react-router"

Mocking react-router-dom hooks using jest is not working

I'm using Enzyme's shallow method to test a component which uses the useParams hook to get an ID from the URL params. I'm trying to mock the useParams hook so

How to load firebase data before the component renders in react?

I have the following files... useAuthStatus.js import {useEffect, useState, useRef} from 'react'; import { getAuth, onAuthStateChanged } from 'firebase/auth';

Cancelling Axios request in React when using React Router Switch

I'm a newbie building an App that utilizes React Router to switch between 3 different components that each utilize Axios to fetch data from an API. I am trying

Get an active route with react-router in ReactJs

I am creating a project using reactjs.In my application i am getting the active route using this: this.context.router.isActive but getting undefined, i am us

How to run a function when user clicks the back button, in React.js?

I looked around and tried to find a solution with React router. With V5 you can use <Promt />. I tried also to find a vanilla JavaScript solution, but not

React-router HashRouter When redirecting root URL with query parameters, route gets appended after params

I'm having the following issue. I am implementing SSO which, after successful sign in, redirects the user to the root uri with the access_token as a query param

Imported components transformed into "/static" urls in react-create-app

I'm having an issue I can't really find any previous answers to or documentation about. I'm loading a component, in a module, on my local machine, "login.jsx,"

Warning: validateDOMNesting(...): <a> cannot appear as a descendant of <a>

I'm trying to use react-router with reactstrap in a create-reat-app .In the routing page i needed to use state for the reactstrap so i converted the router from

React Router target div id in home page

I am using react router specifically the HashRouter since I am trying to host my react app on github pages. Prior to using the HashRouter I was just using the B

React app returning 500 Internal Server Error

I have a react app, created using create-react-app. After I run npm run build, and deploy the app as a static site, everything works except when I refresh the

Why does ngrx/store example app use multiple stores? (how to design store)

I am trying to make a rather big, scalable application and I was told it is best practice to have one single store storing the current global state (including b

Show/Hide menus based on User /* Flexible menu by menu */

I have React App with sidebar menus, but I want to hide few of them based on User Role, but don't want common roles like 'ADMIN' , 'MODERATOR', etc. I want to m

React-router-dom Prompt: Iframe within a page gets unloaded/loaded [closed]

I am working on a react spa to show alert on unsaved form changes. I am using [email protected] Prompt Component for this use-case. The p

How to intercept back button in a React SPA using function components and React Router v5

I'm working in a SPA in React that doesn't use React Router to create any Routes; I don't need to allow users to navigate to specific pages. (Think multi-page q

How to handle React Router with Node Express routing

I am trying to manage a react app with react router and node js server my router in react: <BrowserRouter> <Switch> <PrivateRoute tok

React-router - How to pass data between pages in React?

I am working on a project where I have to pass data from one page to another. For example, I have data on the first page. let data = [ {id:1, name:'Ford', co

Error: useLocation() may be used only in the context of a <Router> component

I have installed react-router-domV6-beta. By following the example from a website I am able to use the new option useRoutes I have setup page routes and returni

./src/App.js Attempted import error: 'Switch' is not exported from 'react-router-dom'

I can't figure it out why doesn't work. I have uninstalled the react-router-dom package and reinstalled it, but I always have the same error. The error I'm gett

Alternative for Prompt in React Router V6

What is the alternative for Prompt in React Router V6, has it been deprecated, and also hooks like usePrompt, useBlocker are also not available. <Prompt mess

ReactJS: [Home] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

I am trying to navigate to "/quiz" when Start Quiz button is clicked. However when I compile my code I am getting the following error on the website applicatio