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

102
Visualizações
how to add styles inside nested routes react router

I am not able to add the style in my app.js file. The div is not working inside the route. Is there any other way to add style inside the route?

<Routes>
  <Route exact path="/" element={auth.token ? <Home > : < Login />} />
  <Route exact path="/register" element={<Register />} />
  <div style={{ marginBottom: "60px" }}>
    <Route element={<PrivateRouter />}>
      <Route exact path="/:page" element={<PageRender />} />
      <Route exact path="/:page/:id" element={<PageRender/>} />
    </Route>
  </div>
</Routes>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Create a layout route that renders the div element and style and an Outlet component for the nested Route components to render their element prop into.

Example:

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

const Layout = () => (
  <div style={{ marginBottom: "60px" }}>
    <Outlet />
  </div>
);

export default Layout;

...

import Layout from '../path/to/Layout';

...

<Routes>
  <Route path="/" element={auth.token ? <Home /> : < Login />} />
  <Route path="/register" element={<Register />} />
  <Route element={<Layout />}>
    <Route element={<PrivateRouter />}>
      <Route path="/:page" element={<PageRender />} />
      <Route path="/:page/:id" element={<PageRender />} />
    </Route>
  </Route>
</Routes>
about 4 years ago · Santiago Trujillo 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