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

133
Views
React-select clearable properties undefined

I am using react-select package but when i click on clearable cross-icon it gives me error

Cannot read properties of undefined (reading 'value')

 <Select
                      className="form_control_country"
                      isClearable
                      onChange={onChangeStateHandler}
                      defaultValue={null}
                      disabled={navigationResponse != null ? true : false}
                      options={stateOptions}
                      placeholder={""}
                    ></Select>

this is onChange function

  const onChangeStateHandler = (e) => {
    setSelectedState(e.target.value);
  };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The parameter of onChange callback is the new value (or values) of the select, not DOM event like standard select.

So you should be able to get the value directly:

  const onChangeStateHandler = (newOption) => {
    // newOption can also be null 
    setSelectedState(newOption?.value);
  };

I'm assuming your options has a value property.

Looking at the TypeScript types it is clear

  onChange: (
    newValue: OnChangeValue<Option, IsMulti>,
    actionMeta: ActionMeta<Option>
  ) => void;
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!