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

133
Views
assign values to variables using react hooks inside map function

If you think this question is stupid, sorry for that and please forgive me because iam Beginner.:)

1) I want to declare variables using react hooks i done like this:

const[adata,setAdata]=useState(   
                    name:"",
                    companyname: ""
                  })

2)I want to assign " name" to the value(name=filteredperson.name,companyname=filteredperson.companyname) that inside map function here, map function code:

    {data.map((filteredPerson, index) => (
<td>{filteredperson.name}</td>
<td>{filteredperson.companyname}</td>

3)Finally,so i assigned my map function values to variables using react hooks, i want to print it on console.

for eg:name:{filteredperson.name} value in console

Note:filteredperson is a map function. I want to assign map values to variables that are using react hooks.

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

0

Your data variable is of type {name: string, companyname: string}, so to assign value to this variable, you call the setter function:

setData({name: NAME_VALUE, companyname: COMPANYNAME_VALUE})

After you set the value of this object, you can print the values with:

console.log(data.name) console.log(data.companyname)

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!