Answer the question
In order to leave comments, you need to log in
Why does the component not see the menu?
Good morning. Please tell me why I can't sort through the menu which I kind of wrote down in the state, but it's empty..
export default function GetNewTender() {
let [nav, setNav] = useState();
const getMenu = async() => {
let menu = await fetch('http://localhost:4000/menu', {method: 'post'});
menu = await menu.json();
return menu
};
useEffect(() => {
setNav(getMenu());
});
return (
<ul className='select'>
<li> Выберите тип {nav.toString()}</li>
<div className="selectContent">
{nav.map(el => (<li onClick={(e) => selectItem(e)} key={el.id}>{el.name}</li>))}
</div>
</ul>
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question