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

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

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