场景描述
页面点击查询,点击分页都是正常,如果点击“查看”,需要跳转到其他页面,这个时候回到原来的列表页面就会造成页面奔溃
报错截图
原因是rowKey写法造成的
- 错误写法
<Table
rowSelection={rowSelection}
scroll={{ x: 2292 }}
columns={useTableColumns({
handleEdit,
handleDel,
handleRevoke,
handleSeeDetail,
handleCopy
})}
rowKey='id'
sticky
loading={tableLoading}
dataSource={tableData}
pagination={{
showTotal: total => `共 ${total} 条记录`,
onChange: (page, pageSize) => handlePageChange(page, pageSize),
hideOnSinglePage: false,
showQuickJumper: true,
showSizeChanger: true,
current: pageData.page,
...pageData
}}
/>
- 正常写法
把rowKey='id'
改写成rowKey={record => record.id}
,这里的id就是要和后端返回的数据对应,只要是唯一就可以了