reactjs - 如何在 React 中将状态传递给 MDBDataTable
问题描述
我对 React 有疑问。我需要将一个对象传递给 React,<MDBDataTable>
但数据处于状态。关于如何实现这一目标的任何想法?
数据必须像这样传递
<MDBDataTable className="text-center" striped hover bordered small data={this.state}
我的状态看起来像这样
this.state = {
column: [
{
id: 'id'
},
{
serialNumber: 'sn'
},
{
name: 'yr'
}
],
rows: null
};
行默认为空,并使用此代码添加
this.setState({rows: data.map(u => ({
id: u.id,
serialNumber: u.login,
yearRange: u.firstName
}))});
当我console.log(this.state)
显示它应该的状态时。两者column
都rows
填充了数据
解决方案
推荐阅读
- jquery - 如何在纯 JavaScript 中切换两个 div 中的两个类?
- ios - 无法添加扩展
- python - 我的功能太长,我被告知要优化
- microsoft-graph-api - 如何使用 Microsoft Graph API 从 Microsoft Team 频道获取 SharePoint 网站 ID?
- azure-ad-b2c - Azure B2C 自定义策略 OpenId 配置错误 AADB2C90022
- php - 你如何在 laravel 5.4 中编写这个 sql 查询?
- azure - 如何通过 ARM 模板创建 Azure AKS 服务
- spring - Spring 安全性将主体信息与请求参数匹配
- python - python re.sub 的行为与 re.search 不一致
- ruby-on-rails - Rails Active Storage 变体选项