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

197
Vistas
I'm trying to redirect the js file using router in react js and bootstrap but unable to redirect

/* this is for my portfolio i want to redirect to main page after a short video*/

//importing packages as required

        import './App.css';
        import React from 'react';
        import Vid from './assets/codingmonkeyvid.mp4'
        import {BrowserRouter, Routes, Route} from 'react-router-dom'
        import Secondary from './Secondary'
    

// creating function to which it can redirect

        function Redirect() {
          return(
            <>
              <BrowserRouter>
                <Routes>
                  <>
                    <Route path = '/' element = {<Secondary />}></Route>
                  </>
                </Routes>
              </BrowserRouter>
            </>
          );
        }
    

//setting interval to redirect

        setInterval(() => {
          Redirect()
        }, 5000);
        

//maincode

        function App() {
          return(
            <div>
              <center>
                <video src={Vid} autoPlay muted id='myVid'></video>
              </center>
            </div> 
          )
        }
       

//end of code

        export default App;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The Route component does not redirect. You need to import and return the Navigate component.

Importing:

import { Navigate } from 'react-router-dom'

The redirect function:

function Redirect() {
    return <Navigate to="/" />;
}

You also need to create a route for the path if you didn't (somewhere in the App component).

function App() {
    return (
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<Secondary />} />
        </Routes>
      </BrowserRouter>
    );
}

Note: if you are using react-router-dom v5, you will need to use its Redirect component instead of Navigate.

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