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

372
Vistas
Uncaught TypeError: Cannot use 'in' operator to search for 'options' in Mumbai

I have an array of Locations consisting data in the form of array:

const locations = ['Mumbai', 'tuljapur', 'Bhagalpur', 'North East', 'Bongaigaon', 'South District', 'Pune', 'Cuttack', 'amritsar', 'East Godavari', 'Chandigarh']

When I am passing this array to react-select as a options prop. It is giving the following error:

ScrollManager.tsx:48 Uncaught TypeError: Cannot use 'in' operator to search for 'options' in Mumbai
    at ScrollManager.tsx:48:1
    at Array.map (<anonymous>)
    at buildCategorizedOptions (ScrollManager.tsx:48:1)
    at Select._this.buildCategorizedOptions (ScrollManager.tsx:48:1)
    at Select._this.buildFocusableOptions (ScrollManager.tsx:48:1)
    at Select.openMenu (ScrollManager.tsx:48:1)
    at Select._this.onInputFocus (ScrollManager.tsx:48:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4161:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4210:1)
    at invokeGuardedCallback (react-dom.development.js:4274:1)

Here's the React Select Component:

 <Select
                className="ml-4 mb-4 w-[180px]"
                placeholder="School Name"
                // isClearable={true}
                options={locations}
                name={"class"}
                // value={selectedFilters.status}
              />

How can I send my array as options in react-select

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

React Select expects the options to be passed as array of object in this format:

{ value: 'value here', label: 'Label here' }

So, you should be passing locations as an array of objects to options prop of React-Select select as:

[
  {  label: "Mumbai", value: "Mumbai" },
  {  label: "tuljapur", value: "tuljapur" },
  ....
]

Reference: https://react-select.com/home#getting-started

Code Sandbox link https://codesandbox.io/s/pb4r2s?module=/example.tsx

about 4 years ago · Juan Pablo Isaza Denunciar
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