diff --git a/src/MUIDataTable.js b/src/MUIDataTable.js index 00e4b92ec..3d7eda621 100644 --- a/src/MUIDataTable.js +++ b/src/MUIDataTable.js @@ -237,7 +237,7 @@ class MUIDataTable extends React.Component { componentDidUpdate(prevProps) { if (this.props.data !== prevProps.data || this.props.columns !== prevProps.columns) { - this.updateOptions(this.props); + this.updateOptions(this.options, this.props); this.setTableData(this.props, TABLE_LOAD.INITIAL, () => { this.setTableAction('propsUpdate'); }); @@ -254,8 +254,8 @@ class MUIDataTable extends React.Component { } } - updateOptions(props) { - this.options = assignwith(this.options, props.options, (objValue, srcValue, key) => { + updateOptions(options, props) { + this.options = assignwith(options, props.options, (objValue, srcValue, key) => { // Merge any default options that are objects, as they will be overwritten otherwise if (key === 'textLabels' || key === 'downloadOptions') return merge(objValue, srcValue); return; @@ -325,9 +325,7 @@ class MUIDataTable extends React.Component { mergeDefaultOptions(props) { const defaultOptions = this.getDefaultOptions(); - this.options = merge(defaultOptions, props.options); - - this.handleOptionDeprecation(props); + this.updateOptions(defaultOptions, this.props); } validateOptions(options) { diff --git a/test/MUIDataTable.test.js b/test/MUIDataTable.test.js index 6d157be12..7d4bed0a1 100644 --- a/test/MUIDataTable.test.js +++ b/test/MUIDataTable.test.js @@ -496,6 +496,16 @@ describe('', function() { assert.deepEqual(state.rowsPerPageOptions, [5, 10, 15]); }); + it('should allow empty array rowsPerPageOptions when provided in options', () => { + const options = { + rowsPerPageOptions: [], + }; + + const shallowWrapper = shallow(); + const state = shallowWrapper.dive().state(); + assert.deepEqual(state.rowsPerPageOptions, []); + }); + it('should render pagination when enabled in options', () => { const options = { pagination: true,