import React, { useEffect, useState } from 'react'; import { Avatar, Divider, List, Skeleton } from 'antd'; import InfiniteScroll from 'react-infinite-scroll-component'; interface DataType { gender: string; name: { title: string; first: string; last: string; }; email: string; picture: { large: string; medium: string; thumbnail: string; }; nat: string; } const App: React.FC = () => { const [loading, setLoading] = useState(false); const [data, setData] = useState([]); const loadMoreData = () => { if (loading) { return; } setLoading(true); fetch('https://randomuser.me/api/?results=10&inc=name,gender,email,nat,picture&noinfo') .then((res) => res.json()) .then((body) => { setData([...data, ...body.results]); setLoading(false); }) .catch(() => { setLoading(false); }); }; useEffect(() => { loadMoreData(); }, []); return (
} endMessage={It is all, nothing more 🤐} scrollableTarget="scrollableDiv" > ( } title={{item.name.last}} description={item.email} />
Content
)} />
); }; export default App;