Вот мой упрощенный код:
import { useEffect, useState } from "react";
function Users() {
const [users, setUsers] = useState([]);
useEffect(() => {
console.log("Fetching users...");
fetch("https://jsonplaceholder.typicode.com/users")
.then((res) => res.json())
.then((data) => setUsers(data));
}, []);
return (
User List
- {users.map((user) => (
- {user.name}
))}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ndency-arr