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