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

188
Vistas
Dynamically display newly added cards in the right Reactjs

I'm working on this project where I need to fetch data, and display a list of custom designed card component using map. All works fine but when I add a new value to the array, it will create a new card with the values I want but default to start from the left.

Is there a way to make the new ones get added to the right side instead?

This is how it looks right now enter image description here

This is how I want it to look (expected) enter image description here

It could also start from index 0 from the right side if that would solve the problem.

Please note that I have already tried to set the direction to RTL but that doesn't solve the problem of how map insert and display new items in the list

Sample code


//fetch data 
function fetchData(){
return data.cards.slice().sort(a, b).(a.toUpperCase()< b.toUpperCase() ? -1 : 1)) 

}

const cardsList = fetchData()

<CardList> 
{
cardsList.map( card => (

<Card key={card.id}>
{card.name}
</Card>

))
}
</CardList>

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

0

Not sure what is CardList and Card component. But this should be possible with display:flex, flex-wrap and justify-content: flex-end; as in below example.

.container {
  display: flex;
  flex-wrap: wrap;
  width: 450px;
  justify-content: flex-end;
}

.card {
  padding: 10px;
  border: 1px solid red;
  margin: 20px;
}
<div class="container">
  <div class="card">index 0</div>
  <div class="card">index 1</div>
  <div class="card">index 2</div>
  <div class="card">index 3</div>
  <div class="card">index 4</div>

</div>

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