如果更改为 false,则 React 在 table 中隐藏操作按钮
React hide the action button in the table if the change is false
如果 elementchange
为假,我如何隐藏操作?
我收到这个错误
TypeError: Invalid attempt to spread non-iterable instance. In order
to be iterable, non-array objects must have a Symbol.iterator
method.
这是我最新的代码
const { elementchange } = route.params;
<Paper className={classes.paper}>
<MaterialTable
title='List of Metadata'
columns={dataTable.columns}
icons={dataTable.icons}
data={dataTable.data}
actions={elementchange &&
<>
{dataTable.actions}
</>
}
style={{width:'100%'}}
options={{
actionsColumnIndex: -1,
pageSize:10,
}}
/>
</Paper>
Actions 需要一个数组,您正在向它传递 JSX。用这样的东西替换它:
actions={elementchange ? dataTable.actions: []}
这应该有效
如果 elementchange
为假,我如何隐藏操作?
我收到这个错误
TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method.
这是我最新的代码
const { elementchange } = route.params;
<Paper className={classes.paper}>
<MaterialTable
title='List of Metadata'
columns={dataTable.columns}
icons={dataTable.icons}
data={dataTable.data}
actions={elementchange &&
<>
{dataTable.actions}
</>
}
style={{width:'100%'}}
options={{
actionsColumnIndex: -1,
pageSize:10,
}}
/>
</Paper>
Actions 需要一个数组,您正在向它传递 JSX。用这样的东西替换它:
actions={elementchange ? dataTable.actions: []}
这应该有效