Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
Not showing any thing on screen while applying authentication in react.js

I was applying authenication in my project in React.js by using protectes routes. First i was using Redirect component from react-router-dom but then i have found out the changes they made in react-router-dom than i applied the navigate component.

import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom';
import './App.css';
import Navigation from './components/shared/Navigation/Navigation';
import Authenticate from './pages/Authenticate/Authenticate';
import Home from './pages/Home/Home';
import Login from './pages/Login/Login';
import Register from './pages/Register/Register';

const isAuth = true;

function App() {
  return (
    <div className="App">

    <BrowserRouter>

    <Navigation/>

    <Routes>
      <Route  exact path='/' element={<Home/>}></Route>
      {/* <Route exact path='/register' element={<Register/>}></Route>
      <Route exact path='/login' element={<Login/>}></Route> */}
      {/* <Route exact path='/authenticate' element={<Authenticate/>}></Route> */}
      <GuestRoute  exact path='/authenticate' element={<Authenticate/>}></GuestRoute>
    </Routes> 

    </BrowserRouter>
     
    </div>
  );
}

const GuestRoute = ({children,...rest}) =>{
  return(
    <Route {...rest} render = {({location})=>{
      return isAuth ?(
         <Navigate  to = '/rooms'state = {{from : location}} replace />
       ) 
       :(
         children 
       )
   
     }}></Route>
  )
  
}

export default App;

This is my code after using the navigate component my screen not showing any thing there must be some kind of logical error in it. Kindly help me to resolve this error.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

your app is showing nothing because the route /rooms does not match any routes in the <Routes /> component

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda