React-bootstrap-table2: TypeError happened on export CSV after js file compression

Created on 20 Oct 2018  路  12Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

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!

bug

All 12 comments

@xujiahang11 I believe your bundle mechanism is wrong but I'm not sure which part cause this issue. It definitely not a bug from react-bootstrap-table2

If you remove gulp-uglify then try again? BTW, I am not familiar with closure compiler. so maybe you can try to use closure compiler to compile only without any minification then run you application directly to see if there's the same error happen.

Thanks

I am also getting this issue, but I am using webpack to uglify my code. my error is very similar:

Uncaught TypeError: s.getData is not a function
    at s.handleExportCSV (main.js?cdd4c96474ec80a14813:25)
    at onClick (main.js?cdd4c96474ec80a14813:25)
    at Object.<anonymous> (main.js?cdd4c96474ec80a14813:51)
    at Object.invokeGuardedCallback (main.js?cdd4c96474ec80a14813:51)
    at Object.invokeGuardedCallbackAndCatchFirstError (main.js?cdd4c96474ec80a14813:51)
    at R (main.js?cdd4c96474ec80a14813:51)
    at w (main.js?cdd4c96474ec80a14813:51)
    at q (main.js?cdd4c96474ec80a14813:51)
    at P (main.js?cdd4c96474ec80a14813:51)
    at L (main.js?cdd4c96474ec80a14813:51)

When I build without minifying, then it succeeds, but shouldn't you want it to work with all minifyers?
I believe that there might be an actual bug. I love the table.
Thanks for the help!

Update:
I spent all yesterday trying to make this work by just excluding this module from being uglified and could not get it working. Would be much appreciated if this could be fixed or some advice given as to how to make this work. Thanks1

I will look into it.

Any update on this issue? Thanks!

https://react-bootstrap-table.github.io/react-bootstrap-table2/blog/2018/10/29/version-bump.html

Try to upgrade to newest version, I'm not very sure if I fixed it, so please help me to check and tag me if the problem still remain, thanks

@AllenFang I am still getting the error after updating to 1.3.1.
I have found that the error only occurs when I set exportAll to false. This might help you in your search to fix the issue. Thanks!

+1. Still getting this error. And it also occurs when I set _onlyExportSelection_ to true.

@AllenFang I am running into the exact same issue as @kmb266, using 1.3.1

thanks you guy, will look into it again 馃憤

Update here?

@AllenFang
Getting this error while clicking export csv button.

button.js:33 Uncaught TypeError: onExport is not a function
at onClick (button.js:33)

Can you please suggest the solution for the same ? Thanks in advance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dillobird picture dillobird  路  3Comments

josefheld picture josefheld  路  3Comments

ethannkschneider picture ethannkschneider  路  3Comments

Randore picture Randore  路  3Comments

cnav007 picture cnav007  路  4Comments