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

158
Views
Mapping inside a map function, while getting the data from the state a of parent component

When it goes to getDropDownOptions, I get this error - Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. I'm not using any componentWillUpdate or componentDidUpdate, neither setting state anywhere related to this functionality. rowInfo is the Items inside an array, that Im mapping. allProducts is the data I'm getting from a parent component.

    return (
      <SelectBox
        options={getDropdownOptions}
        value={{ label: '', value: '' }}
        onChange={e =>
          onItemChange({
            itemKey: headerItem.itemKey,
            arrayIndex: index,
            value: { label: e.value, value: e.value }
          })
        }
        customClass="lineItemDropdown"
      /> ```


const getDropdownOptions = () => {
    const dropDownOptions = allProducts.find(
      product => product.productId === rowInfo.productId
    ).packages;
    return dropDownOptions;
  };

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

0

In your example you are passing a reference to a function for options instead of the value that the function returns.

Right now, if you were to console.log(props.options), you would see a function....but you need an array.

So try this:

<SelectBox
  options={getDropdownOptions()}
  ...       
/>

OR, instead of using a function, just set a variable:

const dropDownOptions = allProducts.find(
      product => product.productId === rowInfo.productId
    ).packages;
    return dropDownOptions;

return (
   <SelectBox
     options={dropDownOptions}
     ...       
   />
)
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!