我正在从 ReactJs 中的 WebAPI 接收 ReactTable 中的数据。
现在,我想将 ReactTable 的数据下载到 CSV 文件中。我可以成功获取数据并在 ReactTable 中查看。但我无法将其保存在 CSV 文件中。
我收到这个错误。TypeError:数据应该是“字符串”、“数组数组”或“对象数组”
这是我的代码。如果我做错了什么,请看看并建议我。请注意,我可以在我的 React Table 中成功接收数据。我只想在 CSV 文件中下载那些 React-Table 数据。
import React,{ Component } from 'react';
import { graphql } from 'react-apollo';
import { gql } from 'apollo-boost';
import ReactTable from 'react-table-6';
import 'react-table-6/react-table.css';
import { CSVLink, CSVDownload } from "react-csv";
class wineParameter extends Component {
render() {
let { data } = this.props;
return (
<div>
<h2> High Rate Wines </h2>
<ReactTable
data={ data.wineclassify}
columns={columns}
defaultPageSize={10}
/>
<CSVLink data={data.wineclassify} headers={columns}>Download CSV</CSVLink>
</div>
);
}
}