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

94
Views
React-Select is not showing selected options on the searchbar

When I try and select an option from the dropdown it doesn't show on the searchbar if I add an if statement inside the onChange handler function, when I remove "if statement" the selected options get displayed on the bar.

                <Select
                  isMulti
                  name="colors"
                  options={cat.subs.map((sub) => {
                    return { value: sub, label: sub.name };
                  })}
                  className="basic-multi-select"
                  classNamePrefix="select"
                  onChange={handleChange}
                />

And this is the change handler function, it works perfectly, but the selected option are not displayed on the searchbar

const handleChange = (newValue, actionMeta) => {
  if (actionMeta.action === "remove-value") {
    removeSubCategory(actionMeta.removedValue.value);
  } else if (actionMeta.action === "select-option") {
    addSubCategory(actionMeta.option.value);
  }
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If the removeSubCategory function removes the value from your data, it won't be available to select again, will it? Please can you provide more context on how those functions modify the data that provides your options.

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!