Bunlong / react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
https://react-papaparse.js.org
MIT License
372 stars 62 forks source link

The Local File demo is not outputting anything in the console #30

Closed simon-musy closed 4 years ago

simon-musy commented 4 years ago

In the demo as well as locally, the following code does not output anything when uploading a file.

import React, { Component } from 'react'
import { CSVReader } from 'react-papaparse'

export default class CSVReader2 extends Component {
  handleOnDrop = (data) => {
    console.log('---------------------------')
    console.log(data)
    console.log('---------------------------')
  }

  handleOnError = (err, file, inputElem, reason) => {
    console.log(err)
  }

  handleOnRemoveFile = (data) => {
    console.log('---------------------------')
    console.log(data)
    console.log('---------------------------')
  }

  render() {
    return (
      <>
        <h5>Click and Drag Upload</h5>
        <CSVReader
          onDrop={this.handleOnDrop}
          onError={this.handleOnError}
          addRemoveButton
          onRemoveFile={this.handleOnRemoveFile}
        >
          <span>Drop CSV file here or click to upload.</span>
        </CSVReader>
      </>
    )
  }
}

Am I missing something? The string parsing demo works like a charm

Bunlong commented 4 years ago

Hi @simon-musy

I get a try on codesandbox, it works.

Screenshot from 2020-06-18 16-40-29

It also work on demo but don't forget to click Parse button.

Screenshot from 2020-06-18 16-44-35

simon-musy commented 4 years ago

Hi @Bunlong, my bad, I thought the handleOnDrop was supposed to output something when uploading the file.

Thanks for the quick reply!

Bunlong commented 4 years ago

Hi @simon-musy You are very welcome. Thank you so much :bowing_man: