Skip to content

TypeError happened on export CSV after js file compression #620

@xujiahang11

Description

@xujiahang11

I was working on a function that export to CSV only selected rows. It went well until I tried to compress my js file. I used several plugins including gulp-minify, gulp-uglify, closure compiler and all got same error:

Uncaught TypeError: c.getSelected is not a function
    at Object.c.handleExportCSV [as onExport] (default.js:956)
    at onClick (default.js:981)
    at Object.y (default.js:70)
    at x (default.js:70)
    at v (default.js:71)
    at t (default.js:72)
    at c (default.js:73)
    at z (default.js:73)
    at d (default.js:72)
    at C (default.js:74)

And this is my code:

const columns = [{
          dataField: 'id',
          text: 'Category ID'
        }, {
          dataField: 'name',
          text: 'Category Name'
        }];

        const selectRow = {
          mode: 'checkbox',
          clickToSelect: true
        };

        const { ExportCSVButton } = CSVExport;

        return(
            <ToolkitProvider
              keyField="id"
              data={ this.state.categories }
              columns={ columns }
              exportCSV={ {**onlyExportSelection: true**} }>
              {
                props => (
                  <div>
                    <ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
                    <hr />
                    <BootstrapTable
                      { ...props.baseProps }
                      selectRow={ selectRow }
                    />
                  </div>
                )
              }
            </ToolkitProvider>
        );

After it, I also tried setting 'exportAll: false' instead of 'onlyExportSelection: true'. Still got an error:

Uncaught TypeError: l.getData is not a function
    at l.handleExportCSV (product.bundle-min.js:1)
    at onClick (product.bundle-min.js:1)
    at Object.<anonymous> (product.bundle-min.js:1)
    at d (product.bundle-min.js:1)
    at product.bundle-min.js:1
    at C (product.bundle-min.js:1)
    at k (product.bundle-min.js:1)
    at j (product.bundle-min.js:1)
    at S (product.bundle-min.js:1)
    at R (product.bundle-min.js:1)

I wonder that is there any mistake or potential name conflict error in your source code? Could you check it out? Thank you so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions