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

501
Visualizações
React Router: How to fix BrowserRouter showing the blank screen

I'm new to JS react and I'm currently working on the routing portion of my project. I'm trying to utilize the BrowserRouter function imported from the react-router-dom package. But upon issuing npm start all I get is a blank white screen as seen in image (2). If I directly call my *LandingPage.js with the code I commented out on image (1) it outputs the screen shown in image (3) which is what I'm trying to output with the BrowserRouter method. Am I missing anything?

1.) enter image description here

2.)

enter image description here

3.) enter image description here

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

0

If you have react-router-dom V6, then you have to use Routes and Route both at a time to make it work.

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

And update the App function.

function App() {
  return (
     
      <BrowserRouter>
       <Header />
       <main className="py-1">
        <Routes>
            <Route path="/" element={<LandingPage/>} />
        </Routes>
      
      </main>
    </BrowserRouter>
  );
}

export default App;

The Documentation has a pretty good example to understand that

Note: If you are using react-router-dom v5 or below then Import and use Switch instead of Routes for this purpose, Switch is been depreciated 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