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

263
Visualizações
How to render components through map according to screen size

I am rendering cryptocurrency cards components and since they are more than a thousand cards, I need to paginate them. I am giving the cardsPerPage manually so sometimes on different screens it look weird. I need to find a way so they can cover the entire page.

const [pageNumber, setPageNumber] = useState(0);

  const cardsPerPage = 28;
  const pagesVisited = pageNumber * cardsPerPage;

  const displayCards = coinData
    .slice(pagesVisited, pagesVisited + cardsPerPage)
    .map((coin) => (
      <CryptoCard
        iconUrl={Logo}
        name={coin.name}
        URL={"www.binance.com"}
        duration="4 minutes ago"
        label1={"Price"}
        data1={coin.quotes.USD.price}
        label2="Exchanges: "
        data2="Binance"
        label3="Symbol:"
        data3={coin.symbol}
        label4="Pair"
        data4={coin.pair}
        label5="Volume: "
        data5={coin.quotes.USD.volume_24h}
      />
    ));

  const pageCount = Math.ceil(coinData.length / cardsPerPage);
  const changePage = ({ selected }) => {
    setPageNumber(selected);
  };
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Determine how many cards are better by screen size, and you can set the amount cards per screen size maybe with a switch, for example:

const cardsPerPage = () => {
    const screenWidth = window.screen.width;
    
    if(screenWidth < 576){ //Mobile Screens extra small
        return 10; //10 cards
    } else if (screenWidth >= 576 && screenWidth < 768) { //small
        return 15; //15 cards
    } else if (screenWidth >= 768 && screenWidth < 992) { //medium
        return 20; //20 cards
    } else if (screenWidth >= 992 && screenWidth < 1200) { //large
        return 40; //40 cards
    } else if (screenWidth >= 1200) { //extra-large
        return 100; //100 cards
    }
}

Also, you can set the number of cols that you want to manage per screen size, I recommend you work with Bootstrap 5 to manage the responsive design and also take advantage of other functionalities and components.

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