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

168
Visualizações
Is there a way to leave just one component and link's content on the page?

Here is the code:

import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Navbar from "./components/navbar/navbar";
import Intro from "./components/intro/intro";
import Services from "./components/services/services";
import Experience from "./components/experience/experience";
import TrelloClone from "./pages/TrelloClone/TrelloClone";
import './App.css'

function App() {
  return (
    <div className="App">
      <BrowserRouter>
        <Navbar />
        <Routes>
          {/* <Route path="/vanillajs" element={SpotifyClone} />
          <Route path="/djangoapi" element={InstagramClone} /> */}
          <Route path="/reactjs" element={<TrelloClone />} />
        </Routes>
      </BrowserRouter>
      <Intro />
      <Services />
      <Experience />
    </div>
  );
}

export default App;

So basically I need to hide(or remove) <Intro />, <Services /> and <Experience /> by clicking the link that leads to '/reactjs' path but leave the <Navbar /> on the page.

edit: grammar and clarifications

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

0

install this history from this link, when your package is installed successfully, create a file history.js and put the below code in this file.

import {createBrowserHistory} from 'history';

export default createBrowserHistory();

import the history file in this file like import history from './history', then you will get the history props and you can console the history props and check which props are coming and you will find pathname in the history props and make a condition and as you can see in the code below.

import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import history from './history'
import Navbar from "./components/navbar/navbar";
import Intro from "./components/intro/intro";
import Services from "./components/services/services";
import Experience from "./components/experience/experience";
import TrelloClone from "./pages/TrelloClone/TrelloClone";
import './App.css'

function App() {
  return (
    <div className="App">
      <BrowserRouter>
        <Navbar />
        <Routes>
          {/* <Route path="/vanillajs" element={SpotifyClone} />
          <Route path="/djangoapi" element={InstagramClone} /> */}
          <Route path="/reactjs" element={<TrelloClone />} />
        </Routes>
      </BrowserRouter>
      {history?.location?.pathname !== '/reactjs' && 
     <>
      <Intro />
      <Services />
      <Experience />
     </>
      }
    </div>
  );
}

export default App;
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