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

163
Views
Select in form - Problem mapping through options, cannot read properties of undefined (reading 'map')

I am creating a SELECT inside a form in which I need to map through an object (I know mapping through an object instead of an array might be a problem). I am using antd to format my code. I would like to know what I am doing wrong.

Right after the React imports I declared my like const networks = [{...},{...},...]

Then my export looks like:

export class BasicDetails extends Component {
  state = {
    selectedOption: null,
  };

  handleChange = selectedOption => {
    this.setState({ selectedOption }, () =>
      console.log(`Option selected:`, selectedOption),
    );
  };

And my render/return looks like

render() {
    const { values, handleChange } = this.props;
    const { selectedOption } = this.state;

    return (
<>

            {/* Chain selector */}

            <Select
              style={{ width: 120 }}
              value={selectedOption}
              onChange={this.handleChange}
              Option={this.props.networks.map((network, index) => {
                return {
                  label: network.name,
                  value: network,
                  key: index,
                };
              })}
            />

Can anybody help me please? I am a junior dev. :) Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved. I was using Option={this.props.networks.map((network, index) instead of Option={this.state.networks.map((network, index)

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!