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

172
Visualizações
How to use static information in react app?

I have a card designed in react. The card needs to appear throughout the project (on different pages).

Each card will have different titles, subtitles, and amount.

How can I go about doing this? I thought about creating an object and then looping through it. Calling the card component on different pages, but this won't allow me to change the content depending on the page.

Card.js

const cards = [
   {title: Card A, subtitle: Card A Subtitle},
   {title: Card A2, subtitle: Card A2 Subtitle},
   {title: Card A3, subtitle: Card A3 Subtitle},
]

{cards.map through cards to display it}

ExamplePageA.js. (Card:3, title: CardA, Subtitle:CardASubtitle....)

<Card />
<OtherStuff />

ExamplePageB.js (Card:2, title: cardB, Subtitle: CardBSubtitle....)

<Card />
<OtherStuffB />
<OtherStuffToo />
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You must pass props to your card component so that you can use it multiple times with different data:

export const Card = (props) => {
  return (
    <div>{props.title}<div/>
    <div>{props.subtitle}<div/>
  )
}

And then you should use it like this:

<Card title="Your title" subtitle="Your subtitle"/>

If you want to map through your cards array you should approach it like this inside of return in your parent component:

{cards.map((card) => <Card title={card.title} subtitle={card.subtitle}/>)}
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