我正在关注排序模型文档(https://material-ui.com/components/data-grid/sorting/#basic-sorting),并且正在使用sortModel并onSortModelChange完全按照文档中的方式使用。但是,加载页面后我立即遇到无限循环(我可以根据 console.log 判断这一点)。
我尝试过的:
if (sortModel !== model) setSortModel(model)在 onSortChange 函数中使用。我总是遇到同样的问题。我正在使用 Blitz.js。
我的代码:
使用状态:
const [sortModel, setSortModel] = useState<GridSortModel>([
{
field: "updatedAt",
sort: "desc" as GridSortDirection,
},
])
Run Code Online (Sandbox Code Playgroud)
行定义:
const rows = currentUsersApplications.map((application) => {
return {
id: application.id,
business_name: application.business_name,
business_phone: application.business_phone,
applicant_name: application.applicant_name,
applicant_email: application.applicant_email,
owner_cell_phone: application.owner_cell_phone,
status: application.status,
agent_name: application.agent_name,
equipment_description: application.equipment_description,
createdAt: formattedDate(application.createdAt),
updatedAt: formattedDate(application.updatedAt),
archived: application.archived,
}
})
Run Code Online (Sandbox Code Playgroud)
列定义:
const …Run Code Online (Sandbox Code Playgroud)