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

121
Visualizações
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 Respostas
Responde à pergunta

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 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