import React from "react";
import { List, NumberField } from "@refinedev/antd";
import { Table } from "antd";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
const PostList: React.FC = () => {
const columns = React.useMemo<ColumnDef<IPost>[]>(() => [
{
id: "id",
header: "ID",
accessorKey: "id",
},
{
id: "title",
header: "Title",
accessorKey: "title",
},
{
id: "hit",
header: "Hit",
accessorKey: "hit",
cell: function render({ getValue }) {
return (
<NumberField
value={getValue()}
options={{
minimumFractionDigits: 1,
maximumFractionDigits: 1,
}}
/>
);
},
},
], []);
const { getHeaderGroups, getRowModel } = useTable({
columns,
});
return (
<List>
<Table dataSource={getRowModel().rows} columns={columns.map(column => ({
title: column.header,
dataIndex: column.accessorKey,
render: column.cell,
}))} />
</List>
);
};
import React from "react";
import { List, NumberField } from "@refinedev/antd";
import { Table } from "antd";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
const PostList: React.FC = () => {
const columns = React.useMemo<ColumnDef<IPost>[]>(() => [
{
id: "id",
header: "ID",
accessorKey: "id",
},
{
id: "title",
header: "Title",
accessorKey: "title",
},
{
id: "hit",
header: "Hit",
accessorKey: "hit",
cell: function render({ getValue }) {
return (
<NumberField
value={getValue()}
options={{
minimumFractionDigits: 1,
maximumFractionDigits: 1,
}}
/>
);
},
},
], []);
const { getHeaderGroups, getRowModel } = useTable({
columns,
});
return (
<List>
<Table dataSource={getRowModel().rows} columns={columns.map(column => ({
title: column.header,
dataIndex: column.accessorKey,
render: column.cell,
}))} />
</List>
);
};