How to extract data to React state from CSV file using Papa Parse?

前端 未结 3 1281
温柔的废话
温柔的废话 2020-12-30 14:24

I\'m using Papa Parse to parse a CSV file for Graphs. I want to store the data in React state after the file is parsed. Papa.Parse() doesn\'t return anything and results are

3条回答
  •  [愿得一人]
    2020-12-30 14:49

    You need to bind the getData():

    function getData(result) {
        console.log(result); // displays whole data
        this.setState({data: result}); // but gets error here
    }.bind(this)
    

提交回复
热议问题