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

209
Views
react hooks: Pass a state setter as an argument to an onChange function?

I already implement that. It works! but could it be expensive ?? if it is then how?

const [neighbourCountryGeneraleDes, setNeighbourCountryGeneralDes] = useState(neighbour_country_generale_des_init);
const [neighbouringProvincePopulationSummary, setNeighbouringProvincePopulationSummary] = useState(neighbouring_province_population_summary_init);

const onChangeInput = (e, data, setData) => {
  const { name, value } = e.target;
  setData({ ...data, [name]: value });
};

JSX

<div style={{ marginBottom: "15px" }}>
  <SearchInputField
    width="785px"
    headText="বন্দরের নাম"
    icon={inputIcon}
    bool={false}
    placeholder="বন্দরের নাম লিখুন"
    name="air_port_name"
    value={neighbourCountryGeneraleDes.air_port_name}
    handleChange={(e) => onChangeInput(e, neighbourCountryGeneraleDes,setNeighbourCountryGeneralDes)}
  />
</div>
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!