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

121
Views
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 answers
Answer question

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 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!