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

114
Vistas
How to render blocks of data from Fetch resource whitout re-render what is already in the screen?

I'm consuming an API, and it returns an array whit length of 370. I want to start rendering only 15, and then, when the user scroll down, render more 15, and so on... PS: The part of getting the viewport height is fine, I already know how to do it. So, focus on the React rendering function only. That's what I have so far, rendering the first 15 items:

export const GamesPage = () => {
  const [data, setData] = useState([]);

  async function getData() {
    const options = {
      method: 'GET',
      url: 'https://free-to-play-games-database.p.rapidapi.com/api/games',
      params: { 'sort-by': 'popularity' },
      headers: {
        'X-RapidAPI-Host': 'free-to-play-games-database.p.rapidapi.com',
        'X-RapidAPI-Key': 'MY_KEY',
      },
    };

    axios
      .request(options)
      .then(function (response) {
        setData(response.data);
      })
      .catch(function (error) {
        console.error(error);
      });
  }

  useEffect(() => {
    getData();
  }, []);

const renderList = () => {
    let reducedArray = [];
    for (let i = 0; i < 15; i++) {
      reducedArray.push(data[i]);
    }

    return reducedArray.map(game => (
      <Col key={game.id} sm={12} md={3} lg={3}>
        <a className='link' href={game.game_url}>
          <Card className='shadow grow bg-dark mb-4'>
            <Card.Img src={game.thumbnail} />
            <Card.Body>
              <Card.Title>
                <p className='c-limit'>{game.title}</p>
                <span className='float-right badge'>Free</span>
              </Card.Title>
            </Card.Body>
          </Card>
          
        </a>
      </Col>
    ));
  };

  return (
      {data.length && renderList()}
  )
}
about 4 years ago · Juan Pablo Isaza
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