Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

85
Vistas
How to use different kinds of navbar components on different pages

I have two different navbar components created for two different subsystems of our project.

App.js

function App() {
  return (
    <>
      <Router>
        <Routes>
          <Route path="/" element={<CirclePage />} />
          <Route
            path = "*"
            element={
              <>
                <Navbar/>
                <Routes>
                  <Route path="/homepage" element={<Homepage />} />
                  <Route path="/events" element={<Events />} />
                  <Route path="/clubs" element={<Clubs />} />
                  <Route path="/notifications" element={<Notifications />} />
                  <Route path="/profile" element={<Profile />} />
                  <Route path="/contact" element={<Contact/>}/>
                </Routes>
              </>
            }
          />

          <Route 
            path = "*"
            element={
              <>
                <NavbarClub/>
                <Routes>
                  <Route path="/homepage-club" element={<HomepageClubs />} />
                  <Route path="/events-club" element={<EventManagement />} />
                  <Route path="/contact-clubs" element={<ContactClubs />} />
                  <Route path="/notifications-club" element={<NotificationsClub />} />
                  <Route path="/profile-club" element={<ClubProfile />} />
              </Routes>
              </>
            } 
            />

        </Routes>
      </Router>
    </>
  );
}

export default App;

Navbar is visible on every screen except the main screen CirclePage. I want Navbar to be visible on homepage, events, clubs, notifications, profile and contact while NavbarClub to be visible in with the -club pages. How can I implement this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Create layout wrapper components for each that renders the specific navbar and an Outlet for nested Route components.

Example:

import { Outlet } from 'react-router-dom';

const NavbarLayout = () => (
  <>
    <Navbar />
    <Outlet />
  </>
);

const NavbarClubLayout = () => (
  <>
    <NavbarClub />
    <Outlet />
  </>
);

App

function App() {
  return (
    <Router>
      <Routes>
        <Route path="/" element={<CirclePage />} />
        <Route path="*" element={<NavbarLayout />}>
          <Route path="homepage" element={<Homepage />} />
          <Route path="events" element={<Events />} />
          <Route path="clubs" element={<Clubs />} />
          <Route path="notifications" element={<Notifications />} />
          <Route path="profile" element={<Profile />} />
          <Route path="contact" element={<Contact />} />
        </Route>

        <Route path="*" element={<NavbarClubLayout />}>
          <Route path="homepage-club" element={<HomepageClubs />} />
          <Route path="events-club" element={<EventManagement />} />
          <Route path="contact-clubs" element={<ContactClubs />} />
          <Route path="notifications-club" element={<NotificationsClub />} />
          <Route path="profile-club" element={<ClubProfile />} />
        </Route>
      </Routes>
    </Router>
  );
}

Edit how-to-use-different-kinds-of-navbar-components-on-different-pages

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda