From 25b2881c7fdfe636897ab62cc46aaef6ee696ce2 Mon Sep 17 00:00:00 2001 From: dsafdasf Date: Wed, 22 Dec 2021 18:41:59 +0000 Subject: [PATCH] feat add the ablity to reset selected rows on table change if needed --- src/MUIDataTable.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/MUIDataTable.js b/src/MUIDataTable.js index ed64ff3ad..d530357e9 100644 --- a/src/MUIDataTable.js +++ b/src/MUIDataTable.js @@ -546,9 +546,18 @@ class MUIDataTable extends React.Component { } } + resetSelectedRows = () => { + this.setState({ + selectedRows: { + data: [], + lookup: {}, + }, + }); + }; + setTableAction = action => { if (typeof this.options.onTableChange === 'function') { - this.options.onTableChange(action, this.state); + this.options.onTableChange(action, this.state, resetSelectedRows); } if (this.options.storageKey) { save(this.options.storageKey, this.state);