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

143
Views
ReactJS: make a select that load all values from api

I'm creating a select (at the moment i'm using React-Select component) to retrive all the result from the api.

The problem is that API gives me back 20 values, so I should find a method to load other 20 values ( as I make another api call )

const option = personList && personList .map((spl) => {
    return {
      value: spl.perCod,
      label: spl.perName
    }
  })

          <Row>
            <Col>
              <Select
                id="perCod"
                name="perCod"
                options={option}
              />
            </Col>
          </Row>

the personList is populated calling the api:

  useEffect(() => {
    sortEntities();
  }, [paginationState.activePage, paginationState.order, paginationState.sort]);

const sortEntities = = () => {
//...
 props.getFilteredEntities(
        search, // i pass there the parameters for the research
        paginationState.activePage - 1,
        paginationState.itemsPerPage,
        `${paginationState.sort},${paginationState.order}`
      ),
}

props.getFilteredEntities in my reducer is:

export const getFilteredEntities: ICrudSearchAction<Person> = (search, page, size, sort) => {
  const params = new URLSearchParams(search) ? new URLSearchParams(search).toString() : null;
  const requestUrl = `${apiUrl}${sort ? `?page=${page}&size=${size}&sort=${sort}` : ''}${sort ? '&' : '?'}${params}`;
  return {
    type: ACTION_TYPES.FETCH_PERSON_LIST,
    payload: axios.get<Person>(`${requestUrl}${sort ? '&' : '?'}cacheBuster=${new Date().getTime()}`),
  };
};

At the moment my select has the first 20 results from api. I should need to load others. How can I do? thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

change your <Select> code with this, you have to add option tag within iteration, to render all options within select tag,

<Select id="perCod" name="perCod">
  {option.map(o=><option key={Math.random()} value={o.perCod} >{o.perName}</option>)} 
</Select>
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!