Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda