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

107
Views
How to load a new page by axios from api after onClick

I'm trying to load a new page with characters and push them to the main massive, but it always returnes Promise, so I can't do it

import React, { useState } from 'react';
import { PersonCard } from './PersonCard';
import { getPersons } from '../../../apies/api';
export const ListOfPersons = (props) => {

const listOfPersons = props.persons
const [newPersons, setNewPersons] = useState([])
const [currentPageNumber, setCurrentPageNumber] = useState(1)

const getNewPersons = () => {
    if (currentPageNumber !== 10) {
      setCurrentPageNumber(currentPageNumber + 1)
      return setNewPersons(getPersons(currentPageNumber))
    } else {
      throw new console.error()
  }
}
return <div>
   {
     listOfPersons && Array.isArray(listOfPersons) ?
     listOfPersons.map(person => {
      return <PersonCard name={person.name} gender={person.gender} />
    }) : []
}
<button onClick={() => {getNewPersons()}}>Загрузить ещё</button>
; };
about 4 years ago · Juan Pablo Isaza
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!