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

123
Vistas
Render a component in a specific section of page

MainComponent.jsx

//other code
<CardGroup>
  <Router>
    {cards.map((value,idx) => { return <TutorialCard key={idx} val={value} /> })}
    <Switch>
      <Route path="/subject/:title" children={(props)=>{<ContentPage {...props}/>}}/>
    </Switch>
  </Router>
</CardGroup>
//other code

ContentPage.jsx

I want to show this component in a specific section/new page.

export default function CotentPage(props){
  return <h1>This is content page-{props.match.params.title}</h1>  
}

TutorialCard.jsx

//this component create links.
export default function tutorialCard({ val }) {
  return (
    <Card border="primary" style={{ width: '18rem' }} className='cards'>
      <Link exact to={`/subject/${val}`}>
        <Card.Header className="text-center">
          <h6>{val}</h6>   
        </Card.Header>
        <Card.Body>
          <img src={cardSvg} className="fitImage"></img>
        </Card.Body>
      </Link>
    </Card>
  );
}

These are links genarated by TutorialCard.jsx component After clicking these links it render ContentPage besides links. But I want to render ContentPage in a new page. how can I achieve this? Please Help!

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

0

The reason is, the cards are rendered independent from your routes. You need to render your cards in another route. Like so:

<Router>
  <Switch>
    <Route
      path="/"
      exact
      children={() => (cards.map((value, idx) => <TutorialCard key={idx} val={value} />))}
    />
    <Route
      path="/subject/:title"
      children={(props) => <ContentPage {...props} />}
    />
  </Switch>
</Router>
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