const App = `import {Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, getKeyValue, Spinner, Button} from "@nextui-org/react"; import {useAsyncList} from "@react-stately/data"; export default function App() { const [page, setPage] = React.useState(1); const [isLoading, setIsLoading] = React.useState(true); let list = useAsyncList({ async load({signal, cursor}) { if (cursor) { setPage((prev) => prev + 1); } // If no cursor is available, then we're loading the first page. // Otherwise, the cursor is the next URL to load, as returned from the previous page. const res = await fetch(cursor || "https://swapi.py4e.com/api/people/?search=", {signal}); let json = await res.json(); if (!cursor) { setIsLoading(false); } return { items: json.results, cursor: json.next, }; }, }); const hasMore = page < 9; return ( ) : null } classNames={{ base: "max-h-[520px] overflow-scroll", table: "min-h-[420px]", }} > Name Height Mass Birth year } > {(item) => ( {(columnKey) => {getKeyValue(item, columnKey)}} )}
); }`; const react = { "/App.jsx": App, }; export default { ...react, };