Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!