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

150
Visualizações
Is there a simpler way to Dynamicaly return a React State Value through a Key passed down?

Good Morning, i just have a question about generating Dynamic forms. I am looping through an array of objects and for each Genre i am generating a drop down field, i am also filtering a list of items to find what belongs in which drop down list. So my question is is there a way to dynamically assign the drop down list a value that is stored above as so?

 const [company, setCompany] = React.useState([]);
const [division, setDivision] = React.useState([]);
const [jobDescription, setJobDescription] = React.useState([]);
const [businessUnit, setBusinessUnit] = React.useState([]);
const [region, setRegion] = React.useState([]);
const [costCenter, setCostCenter] = React.useState([]);
const [personType, setPersonType] = React.useState([]);


  function getMenuItemsForType(type){
    let filtered = limiters.filter(x => x.limiter_TypeOption === type.limiterTypeId);
   return  Object.keys(filtered).map((x) => {
        return (<MenuItem value={filtered[x].limiterOptionId}>{filtered[x].limiterOptionName} </MenuItem>)
    })
}

{Object.keys(types).map((x) => {
                                        return (
                                            <div className="m-3">
                                                <FormControl variant="standard" sx={{ m: 1, minWidth: 1200 }}>
                                                    <InputLabel id="demo-simple-select-standard-label">{types[x].limiterTypeName}</InputLabel>
                                                    <Select
                                                        labelId="demo-simple-select-standard-label"
                                                        id="demo-simple-select-standard"
                                                        value={x == 0 ? company : x == 1 ? division : x == 2 ? jobDescription : x == 3 ? businessUnit  :x == 4 ? region : x == 5 ? costCenter : personType }
                                                        label={types[x].limiterTypeName}
                                                        onChange={(itm) => setTypeValue(itm.target.value[0], x)}
                                                        style={{width: '800px'}}
                                                        multiple
                                                    >
                                                       {getMenuItemsForType(types[x])}

                                                    </Select>
                                                </FormControl>
                                            </div>
                                        );
                                    })}
about 4 years ago · Juan Pablo Isaza
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