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

189
Views
Passing useState value to React input component

I have created a React component that allows the user to filter a list by typing into an input, I have simplified the component into the below:

const value = filteredOptions
   .filter((option) => option.selected)
   .map((option) => option.label)
   .join(",");

const [input, setInput] = useState(value);

const handleSearch = (e) => {
   e.preventDefault();
   setInput(e.target.value);
};

return (
<InputSearch 
   value={input}
   onChange={handleSearch}
/>
<SelectOption
   key={option.code}
   option={option}
   onClick={onValueChange}
/>

);

value is null by default (and is populated with a string value when selected) - this works. what I would like to do however is feed the value into my input state so that the input state can be updated either by typing into the input (which works currently) or by selecting a value.

about 4 years ago · Juan Pablo Isaza
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!