I am trying to render the team field of the array that I am getting from the API. console.log(data) successfully logs it, but when I try to render it, it simply does not show anything. Thank you for the help!
Home.js
const Home = () => {
const [data, setData] = useState();
const getData = async () => {
try {
const res = await fetch('url');
const data = await res.json();
setData(data);
console.log(data);
} catch (error) {
console.log(error)
}
}
useEffect(() => {
getData();
}, [])
return (
<div>
Home
{data.map((item, i) => {
<h1 key={i}>{item.team}</h1>
})}
</div>
);
}
Data structure of array
0: {Team: 'Cannons', Win: '4', Loss: '2'} 1: {Team: 'Racers', Win: '6', Loss: '0'}