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

144
Visualizações
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 Respostas
Responde à pergunta

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 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