javascript - 在表格组件之外定义的默认列,破坏了代码
问题描述
如果未调用默认列之外的定义(未定义单元格和过滤器函数)并且我收到此错误错误:渲染器错误☝️,参考代码,
export const defaultColumn = {
// Set our editable cell renderer as the default Cell renderer
Cell: EditableCell,
// Let's set up our default Filter UI
Filter: FilterRow,
};
const CustomTable: FC<CustomTableProps> = (props) => {
const {
columns,
data,
setData,
updateMyData,
skipPageReset,
updateGuest,
deleteGuest,
selectedProjectId,
} = props;
const {
getTableProps,
headerGroups,
prepareRow,
page,
gotoPage,
setPageSize,
preGlobalFilteredRows,
setGlobalFilter,
state: { pageIndex, pageSize, selectedRowIds, globalFilter },
} = useTable(
{
columns,
data,
defaultColumn,
autoResetPage: !skipPageReset,
// updateMyData isn't part of the API, but
// anything we put into these options will
// automatically be available on the instance.
// That way we can call this function from our
// cell renderer!
selectedProjectId,
updateMyData,
updateGuest,
},
useGlobalFilter,
useFilters,
useSortBy,
usePagination,
useRowSelect,
但是如果我将这个 defaultColumn 对象放在 CustomTable 中,那么代码就可以正常工作,如下所示,
const CustomTable: FC<CustomTableProps> = (props) => {
const defaultColumn = {
// Set our editable cell renderer as the default Cell renderer
Cell: EditableCell,
// Let's set up our default Filter UI
Filter: FilterRow,
};
const {
columns,
data,
setData,
updateMyData,
skipPageReset,
updateGuest,
deleteGuest,
selectedProjectId,
} = props;
const {
getTableProps,
headerGroups,
prepareRow,
page,
gotoPage,
setPageSize,
preGlobalFilteredRows,
setGlobalFilter,
state: { pageIndex, pageSize, selectedRowIds, globalFilter },
} = useTable(
{
columns,
data,
defaultColumn,
autoResetPage: !skipPageReset,
// updateMyData isn't part of the API, but
// anything we put into these options will
// automatically be available on the instance.
// That way we can call this function from our
// cell renderer!
selectedProjectId,
updateMyData,
updateGuest,
},
useGlobalFilter,
useFilters,
useSortBy,
usePagination,
那么为什么方法一不起作用?
解决方案
推荐阅读
- ios - 测试 iOS IAP 的退款
- python - 路由器不响应欺骗性 DNS 查询
- azure - How to archive old CosmosDB data to Azure Table using Azure Data Factory when CosmosDB collection documents have different properties?
- angular - 当从 Angular 中的 API 获取选项时,在选择的对象中设置选项
- jboss - 连接被拒绝并且无法连接到控制器错误
- clickhouse - 为什么 system.events 中的 InsertedRows 会减少?
- python - Auto-Py-To-Exe - win32api - ModuleNotFoundError
- java - 微调器值未正确设置
- java - 实现 Trie 数据结构的问题
- amazon-web-services - AWS Elasticsearch IAM 作为主用户获取 AuthorizationException 试图放置数据