Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!