gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

customFilterListOptions.update ignores return values #1469

Open timharsch opened 4 years ago

timharsch commented 4 years ago

customFilterListOptions.update ignores return values. In editors where you receive warnings about reassign to parameters (disable with // eslint-disable-next-line no-param-reassign ), one might be attempted to make a copy of filterList and return the copy, but this won't work.

Expected Behavior

returning a deep copy of filterList should work.

Current Behavior

This line of code https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/MUIDataTable.js#L1389

assigns to function parameter (unsafe per eslint rules)

When the function exits changes are lost.

Further, line 1403, does not accept changes to filterList if there had been any: https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/MUIDataTable.js#L1403

Also, this line of code in the example is meaningless (even though the function works correctly because it assigns directly to array elements by reference) https://github.com/gregnb/mui-datatables/blob/ae1d49a61ddafd2a83ac445f279a0a67c434e3de/examples/customize-filter/index.js#L132

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Your Environment

Tech Version
Material-UI
MUI-datatables
React
browser
etc
timharsch commented 3 years ago

Has this been investigated yet?