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

123
Visualizações
How to set object value one by one in into text field using map function in reactjs

I render textfile using the map function according to my array. Now I have an object and I need to set this object value into rendered out text field one by one. But I don't know the way to do this.

This is my object -

const myObject={en: 'This is a good store', fr: "C'est un très bon magasin", ja: 'これは完全に良い店です'};
     {
        locals.map((item, index) => {
           return basicDetails(item, index, myObject);
         })
     }

const basicDetails = (item, index, myObject) => {
    return (
        <Grid>
             <Grid item xs={12}>
                    <CssTextField
                        value={myObject}
                        autoFocus
                        fullWidth
                        variant="outlined"
                        label="Shop Tagline"
                    />
              </Grid>
    );
};

I just need to set my object value one by one into a textField. I try to do this my result is [object Object].

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're getting [object Object] because the value you're passing to the CssTextField component is your entire object instead of one of its attributes.

I'm not sure what locals contains but my guess would be that you need to change this

locals.map((item, index) => {
 return basicDetails(item, index, myObject);
})

to this, assuming locals is an array that contains values such as ['en', 'fr', 'ja'].

locals.map((item, index) => {
 return basicDetails(item, index, myObject[item]);
})
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