Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!