After fetching the data and getting the json response, you can start by putting the result
in your state and dynamically render a card for each user.
Here's some starter code for your desired behaviour
import React, { useEffect, useState } from "react";
const Card = (props) => {
const { user } = props;
return <div>
<div>{user.gender}</div>
<div>{user.name.title} {user.name.first} {user.name.last}</div>
<hr />
</div>;
};
export default function App() {
const [users, setUsers] = useState([]);
useEffect(() => {
const url = "https://randomuser.me/api/?results=5";
const fetchData = async () => {
try {
const response = await fetch(url);
const json = await response.json();
const {results} = json;
// Only put the results in state, ie, the actual users array
setUsers(results);
} catch (error) {
console.log("error", error);
}
};
fetchData();
}, []);
return (
<div>
{users.map((user) => (
<Card key={user.email} user={user} />
))}
</div>
);
}