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

148
Visualizações
i want different navbar on my admin routes
import Navbar from "./components/Navbar.js"
import Footer from "./components/Footer.js"
import './index.css'
import HomePage from "./pages/HomePage/HomePage.js";

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




import ProductPage from "./pages/ProductPage.js";
import  CreateProduct  from './pages/admin/CreateProduct'

function App() {
  return (
    <div className="App">
      <>
      
      
      <Navbar/>
     
      <Routes>
        <Route exact path="/" element={<HomePage/>} />
        <Route exact path="/product/:id" element={<ProductPage />}/>
        
      </Routes>
     
      <Footer/>

      
    <Routes>
       <Route exact path="sarangAdmin/create-product" element={<CreateProduct/>} />
    </Routes>

      
      </>
    </div>
  );
}

export default App;

As you can see in the route of sarangAdmin i dont want the default navbar and fotter appear i want to create a new one for the admin the problem is then when i going on this route i am seeing navbar nad footer but not my create componenet what i want is that i should not see the navbar and footer component and see my create-product componenet

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

0

I think it's better that you change Footer & Navbar component

at first add location to app params app({ location }) then


{location.pathname!=='sarangAdmin/create-product'?<Footer/>}

I hope this code will help you

import Navbar from "./components/Navbar.js"
import Footer from "./components/Footer.js"
import './index.css'
import HomePage from "./pages/HomePage/HomePage.js";
import {Routes,Route} from "react-router-dom";

import ProductPage from "./pages/ProductPage.js";
import  CreateProduct  from './pages/admin/CreateProduct'

const App = ({location}) => {
  return (
    <div className="App">
      {location.pathname!=='sarangAdmin/create-product'?<Navbar/>:null}
      <Routes>
        <Route exact path="/" element={<HomePage/>} />
        <Route exact path="/product/:id" element={<ProductPage />}/>
        <Route exact path="sarangAdmin/create-product" element={<CreateProduct/>} />
      </Routes>
      {location.pathname!=='sarangAdmin/create-product'?<Footer/>:null}
    </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