我正在使用反应表 7 来显示数据。数据包含几个嵌套对象。
例子:
incident: {
incidentId: 123,
incidentName: "fooBar",
incidentDescription: "something bad happened here",
actionsTaken:[{
actionId: 89,
actionDescription: "We did something here",
responseStatusList :[{
responseId:67,
reponseType:"written warning",
dateIntiated: 04/01/2020
}],
}]
}]
}
我可以做主表(即事件级别)及其子组件(即操作),但是当我尝试为操作做一个子组件时,我有一个错误React.useCallback" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function
表代码:
<ReactTable
columns={columns}
data={data}
rowOnClick={true}
headerColor="ddw"
showPagination={true}
rowClickHandler={(e) => console.log("")}
renderRowSubComponent={React.useCallback(
({ row }) =>
row.original.enforcementActionsList.length > 0 ? (
<ReactTable
headerColor="dwq"
data={row.original.enforcementActionsList}
columns={enforcementColumns}
rowOnClick={true}
rowClickHandler={(e) => console.log("")}
renderRowSubComponent={React.useCallback(
({ row }) =>
row.original.responseStatus.length > 0 ? (
<ReactTable
headerColor="dwq"
data={row.original.responseStatus}
columns={statusColumns}
/>
) : (
"No data"
),
[]
)}
/>
) : (
"No data"
),
[]
)}
如何使用 React-Table 7 在子组件内创建子组件?