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

258
Views
How to Get value of select onChange in Functional Component in React

Im Using ant design pro with react to create form, but i cannot save the value of select using hooks. i Shows a errorn errorenter image description here

const ExistingGroup = (props) => {
  const [group,setGroup] = useState([]);

  const saveGroup = (event) => {
    setGroup(event.target.value);
  }
  return (
    <PageContainer header={{ title: '' }} ghost>
      <Card bordered={false} style={{ width: '100%' }}>
        <Form>
          <Form.Item>
            <Select value={group} onSelect={saveGroup}>
              <Option value='1'>1</Option>
              <Option value='2'>2</Option>
            </Select>
            {group}
          </Form.Item>
        </Form>
      </Card>
    </PageContainer>
  );
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you read the documentation of Select, the onSelect method is called with the value of the selected element.

onSelect Called when an option is selected, the params are option's value (or key) and option instance
function(string | number | LabeledValue, option: Option)

so you want

const saveGroup = (value) => {
  setGroup(value);
}

Also, since it is not multiselect, you should use a single value for the group and not an array.

const [group,setGroup] = useState(null);
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!