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

171
Visualizações
Using Select prop 'isSearchable' with JSX

I am trying to make my react-select searchable but I have run into a problem. Basically, the label for my options needs to be in JSX since my client wants to see the contact information of a user at a glance. However, I think the Select prop 'isSearchable' only works when the value is a string. This is what my code looks like:

The data I pass into the 'options' prop of Select:

const createContactDisplay = (data) => {
    return data.map((contact) => ({
      label: (
        <Contact>
          <p>{contact.value.firstName}</p>
          <p>{contact.value.lastName}</p>
          <p>{contact.value.email}</p>
        </Contact>
      ),
      value: contact.key
    }));
  };

I then pass in my filtered contacts as the data above and set the options prop of React select to that state.

Any suggestions on what I should do would be much appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The Select from react-select accepts an array of options where each option is an object with a label and value properties. If you want to use the search function, you need to convert to the option format that Select can understand:

const options = originalOptions.map((o) => ({
  label: o.contact.value.firstName,
  value: o.contact.value.firstName,
  data: o.contact.value, // to reference custom data field if needed
}));
<Select options={options} {...} />

Codesandbox Demo

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