mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-04 21:19:27 +08:00
* refactor: 表格拆分模块化 * refactor: 表格拆分模块化 * refactor: code splitting of the table component (#120) * missing TableIndex * refactor: 表格拆分模块化 * code format Co-authored-by: chenos <chenlinxh@gmail.com>
17 lines
552 B
TypeScript
17 lines
552 B
TypeScript
import { useContext } from 'react';
|
|
import { useTable } from './useTable';
|
|
import { TableRowContext } from '../context';
|
|
|
|
export const useTableIndex = () => {
|
|
const { pagination, props } = useTable();
|
|
const ctx = useContext(TableRowContext);
|
|
const { pageSize, page = 1 } = pagination;
|
|
console.log({ pageSize, page }, ctx.index);
|
|
return ctx.index + (page - 1) * pageSize;
|
|
if (pagination && !props.clientSidePagination) {
|
|
const { pageSize, page = 1 } = pagination;
|
|
return ctx.index + (page - 1) * pageSize;
|
|
}
|
|
return ctx.index;
|
|
};
|