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

157
Visualizações
how to get two kinds of components structure in single react app

i have a react app in which i want that if user route start with admin it should have a different navbar

lets take example

normal page

<NormalNavbar/>

<NormalHeader/>
<NormalBody/>
<NormalFooter/>

But if i have the admin route then i want to have

<AdminNavbar/>
<AdminHeader/>
<AdminBody/>
<AdminFooter/>

The issue is when we wind it inside the Routes then we decide the normal components which are loading i will paste the example below

return (
    <div className="App">
      <>
        <Navbar />
        <Routes>
          <Route exact path="/" element={<HomePage />} />
          <Route exact path="/product/:id" element={<ProductPage />} />
          <Route exact path="sarangAdmin/create-product" element={<CreateProduct />} />
          <Route exact path="login" element={<Login />} />
          <Route exact path="profile" element={<Profile />} />
          <Route exact path="register" element={<Register />} />
        </Routes>
        <Footer />
      </>
    </div>
  );

You can see my current navbar and footer going to be same

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

0

you can put elements with conditions like that

{isAdmin? <AdminNavbar> : <NormalNavbar> }

OR

in the navbar component view different menu

about 4 years ago · Juan Pablo Isaza Relatório

0

See the above answers is good but its not the optimal solution I wanted so I get the solution by looking other git repository here is the repository that shows how you should do it in a perfect way make route component structure and then you can render them conditionally which I wanted in my case the most optimum solution to my question

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