index.tsx 854 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import useRequest from "@ahooksjs/use-request";
  2. import { Table } from "antd";
  3. import React from "react";
  4. import "./index.less";
  5. const columns: {
  6. title: string;
  7. dataIndex: string;
  8. key: string;
  9. render?: (text: string) => JSX.Element;
  10. }[] = [
  11. {
  12. title: "Name",
  13. dataIndex: "name",
  14. key: "name",
  15. render: (text: string) => <a href="">{text}</a>,
  16. },
  17. {
  18. title: "Email",
  19. dataIndex: "email",
  20. key: "email",
  21. },
  22. {
  23. title: "Website",
  24. dataIndex: "website",
  25. key: "website",
  26. },
  27. ];
  28. export const User: React.FC = (props: any) => {
  29. const { data, error, loading } = useRequest("/api/users");
  30. return (
  31. <div className="user-wrapper">
  32. <Table
  33. size="small"
  34. columns={columns}
  35. dataSource={data}
  36. rowKey={(record) => record.id}
  37. loading={loading}
  38. />
  39. </div>
  40. );
  41. };