所以我有一个带有 useTable 的 JavaScript 类。在 Java 脚本中,它的使用如下
import {useTable, useFilters,useAsyncDebounce,useSortBy,usePagination,} from "react-table";
const {getTableProps,getTableBodyProps, headerGroups, page,prepareRow,state,visibleColumns, nextPage,pageOptions,pageCount,previousPage,canPreviousPage,canNextPage,setPageSize,gotoPage
} = useTable({columns,data,defaultColumn,filterTypes,initialState: { pageSize: 10, pageIndex: 0 }
},useFilters, useSortBy,usePagination);
我正在将我的 javascript 项目转换为打字稿。
在打字稿中,该useTable
行给出了错误。
例子 :Property 'page' does not exist on type 'TableInstance<object>'.ts(2339)
该initialState
属性给出了我的以下错误
Type '{ pageSize: number; pageIndex: number; }' is not assignable to type 'Partial<TableState<object>>'.
Object literal may only specify known properties, and 'pageSize' does not exist in type 'Partial<TableState<object>>'.ts(2322)
index.d.ts(172, 5): The expected type comes from property 'initialState' which is declared here on type 'TableOptions<object>'
如何useTable
在 Typescript 中编写该行?