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

246
Visualizações
Content disappears when using the <Route> tag

When ever i add a <Route> tag to the code everything just disappears from the screen!

the code is fine i guess! there is no warnings showing!!

the output before adding the <Route> tags a picture before the route tags

and when i add a <Route> tag the output is just not there anymore!!!!

the code before adding the tag:

import React from "react";
import "./App.css";
import Header from "./Header";
import { BrowserRouter, Route } from "react-router-dom";


function App() {
  return (
    <div className="App">
      <BrowserRouter>
        <Header />
      </BrowserRouter>
    </div>
  );
}

export default App;

and the code after is really the same but with adding the tags :

import React from "react";
import "./App.css";
import Header from "./Header";
import { BrowserRouter, Route } from "react-router-dom";

function App() {
  return (
    <div className="App">
      <BrowserRouter>
        <Header />
        <Route></Route>
      </BrowserRouter>
    </div>
  );
}

export default App;

And when i added the tags the content disappeared !

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

0

Check you're package.json if the version of react-router-dom is 6 then downgrade it to 5 thats where error comes from.

I know this because now npm install install version 6 as its default version but the tutorials and knowledge about react router on line is still for version 5.

so on your package.json change version from 6 to 5.3.0 and run npm install on your terminal

about 4 years ago · Juan Pablo Isaza Relatório

0

Since the route tag is empty, you aren't returning anything. You need to pass the path and the component that should be rendered for each path. In this case considering you have a single path and want to show Hello World!! when the app starts, you should add

<BrowserRouter>
    <Route exact path="/" component={App} />
</BrowserRouter>

This will render your App component when you start the app. You can add other components for other routes similarly.

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