无法获取“ __parsed_extra”数据

时间:2019-10-07 22:05:15

标签: arrays reactjs papaparse

我正在尝试将数据存储在名为__parsed_extra的属性中(参见图片):

enter image description here

这是我的代码:

import React, { Component } from "react";
import Papa from "papaparse";

export default class Player extends Component {
  constructor(props) {
    super(props);

    this.state = {
      data: []
    };

    this.updateData = this.updateData.bind(this);
  }

  UNSAFE_componentWillMount() {
    var csvFilePath = require("./training13Sep.csv");
    Papa.parse(csvFilePath, {
      header: true,
      skipEmptyLines: true,
      download: true,
      complete: this.updateData
    });
  }

  updateData(result) {
    const data = result.data;
    this.setState({ data: data });
    console.log(this.state.data);
  }

  render() {
    console.log(this.state.data[15].__parsed_extra[1]);

    return (
      <table>
        <tr>
          <th>Player</th>
          <th>Nationality</th>
          <th>Age</th>
          <th>Player Number</th>
          <th>Signed</th>
          <th>Wage</th>
          <th>Position</th>
          <th>Description</th>
          <th>Height</th>
          <th>Weight</th>
          <th>Social Networks</th>
        </tr>
      </table>
    );
  }
}

我收到错误消息:

  

TypeError:无法读取未定义的属性'__parsed_extra'

怎么了?

0 个答案:

没有答案