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

96
Views
React pass state to a map function

I need to pass a state to a map function

const MenuList = ({login, ìsAuthenticated}) => {
    const [isAuthenticated] = useState(true)
    menuItem.items.push(isAuthenticated)
    console.log(menuItem)
    const navItems = menuItem.items.map((item) => {
        switch (item.type) {
            case 'group':
                return <NavGroup key={item.id} item={item} />;
            case 'authGroup':
                if (ìsAuthenticated){
                    return <NavGroup key={item.id} item={item} />;
                }else{
                    return <div/>;
                }

This is my actual code

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

0

You have to add more code. Do you want to pass the state as a parameter of the map? or inside the switch command?

Also isAuthenticated is a prop on your component and after you create a new const variable with the same name. Why you do this?

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!