Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
how do I make a 404 redirect with react router 6?

In react router 5 I could use a but that has been removed from react router 6. I think it's been replaced with , but that throws a security error for this usecase... For whatever reason.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Redirect is no longer in the react-router version 6. For react-router-dom v6, You can use Navigate instead of Redirect. Here is the example:

import {Routes, Route, Navigate } from "react-router-dom";

function App() {
    return (
        <>
            <Routes>
                <Route path="/404" element={<div>Page Not Found/div>} />
                <Route path="*" element={<Navigate replace to="/404" />} />
            </Routes>
        </>
    );
}
about 4 years ago · Juan Pablo Isaza Relatório

0

As of v6:

  • Remove <Redirect>s inside <Switch>

  • Remove any <Redirect> elements that are directly inside a <Switch>.

// Change this:
<Switch>
  <Redirect from="about" to="about-us" />
</Switch>

// to this:
<Switch>
  <Route path="about" render={() => <Redirect to="about-us" />} />
</Switch>
  • Normal elements that are not inside a <Switch> are ok to remain. They will become <Navigate> elements in v6.
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda