Mui-datatables: Invalid attempt to spread non-iterable instance

Created on 12 Dec 2019  路  5Comments  路  Source: gregnb/mui-datatables

Hello, i'm currently working on a project using mui-datatables and i needed to comment the following code because it crashes the project when i use the "Select/Unselect all":
image

I didn't change the code, i even tried to use mui-datatables on other projects and i had the same error.

Expected Behavior

Select/Unselect all like the codesandbox example allows.

Current Behavior

This is what happens when i click on the checkbox:
image

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 0.3.9 |
| MUI-datatables | 2.12.4 |
| React | 16.8.6 |
| browser | Chrome, Firefox |

bug

Most helpful comment

@xStorm11 @gabrielliwerant I can verify this. I've fixed this in PR https://github.com/gregnb/mui-datatables/pull/1077/ - it only occurs if you update babel and other packages though. It won't occur in the current setup. It's due to this line:

https://github.com/gregnb/mui-datatables/pull/1077/files#diff-4f4aff53b74d2c551e37786d32b82e3aL1164

"prevState.selectedRows" shouldn't be spread over. If you do a console.dir on it, you'll see why it can't be spread over (see https://github.com/gregnb/mui-datatables/pull/692#issuecomment-529515167 for more info). The version of babel this project uses just ignores the error, but it pops up if you update babel.

This PR also describes the issue: https://github.com/gregnb/mui-datatables/pull/692 (but it gives a faulty solution)

And actually, my response in that PR better explains exactly what is happening.

All 5 comments

Hello @xStorm11, is your version of Material-UI given in this ticket the actual version you are using to produce the error? If so, note that this version is very out of date, and could be the source of your problem. See if upgrading to the latest fixes your issue (though you may need to change some other things to get it to work). If the problem persists after upgrading your Material-UI version, then I'll need to see a minimal codesandbox example that demonstrates the issue so I can find out what may be happening.

@xStorm11 @gabrielliwerant I can verify this. I've fixed this in PR https://github.com/gregnb/mui-datatables/pull/1077/ - it only occurs if you update babel and other packages though. It won't occur in the current setup. It's due to this line:

https://github.com/gregnb/mui-datatables/pull/1077/files#diff-4f4aff53b74d2c551e37786d32b82e3aL1164

"prevState.selectedRows" shouldn't be spread over. If you do a console.dir on it, you'll see why it can't be spread over (see https://github.com/gregnb/mui-datatables/pull/692#issuecomment-529515167 for more info). The version of babel this project uses just ignores the error, but it pops up if you update babel.

This PR also describes the issue: https://github.com/gregnb/mui-datatables/pull/692 (but it gives a faulty solution)

And actually, my response in that PR better explains exactly what is happening.

First of all, thank you very much for answer me @gabrielliwerant and @patorjk .
I follow the changes @patorjk made on newRows and it fixes my problem. I knew this was something wrong with babel but i only had this issue using mui-datatable.
Once again, thank you!

You're welcome @xStorm11.

Keeping this open until the fix is merged in, so it can be tracked.

Fixed as of version 3 of the table.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kylane picture kylane  路  3Comments

demoreno picture demoreno  路  4Comments

Andy1408 picture Andy1408  路  4Comments

aramkoukia picture aramkoukia  路  3Comments

chapmanjacobd picture chapmanjacobd  路  4Comments