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

233
Vistas
react-select onChange target value undefined error - in nextjs

I am new to react/nextjs and im getting the error "Cannot read properties of undefined (reading 'value')". I have tried a few different things, like using select as just a html tag, I have searched the react-select document, but can not find anything that helps with this issue.

enter image description here

Here is my code:

import { useState } from 'react';
import Select from 'react-select';      
import styles from '../src/styles/Flex.module.scss'

const FlexSidebarContainer = ({ sidebarProps }) => {

  const options = sidebarProps.options

  const [value, setValue] = useState("")
    
      const handleOptionChange = (e) => {
        let value = e.target.value
        setValue({ value })
      }

      return (
        <form className={styles.form}>
          {options.map((option, index) => {
            return (
              <div key={index} className={styles.form_item}>
                <div className={styles.form_label_wrap}>
                  <Select className={styles.form_item_wrap}
                    onChange={handleOptionChange}
                    options={option.items.map(item => ({ value: item.value, label: item.item }) )}
                    defaultValue={option.items.map(item => ({ label: item.item }) )}
                    instanceId={option.items.map(item => ({ instanceId: item.item }) )}
                  />
                </div>
              </div>
            );
          })}
        </form>
      )
}

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

0

Select is not a HTML tag here and onChange will not work on it. It's a custom component so event will be undefined. Either use a select HTML tag or if you are using custom component namely "Select" then use custom event handler which will be passed as props to Select component.

    <select>
      <option></option>
    </select>
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