0
I’m having some difficulty to get the values that are of my function and pass them to a list, follow the code:
const [listaPais, setListaPais] = useState<{ id: number; name: string }[]>(
[]
);
useEffect(() => {
setListaPais([
{ id: 1, name: "pais" },
{ id: 2, name: "pais 2" },
]);
}, []);
{listaPais.map((_item, index) => (
<MenuItem key={index} value={''}>
{}
</MenuItem>
))}
_item.name
and_item.id
? Since the object has aid
, avoid using theindex
as key– Rafael Tavares