From 5e63d6ae59434bb0ff586fd186019c42c9487a11 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Wed, 15 Aug 2018 23:08:46 +0800 Subject: [PATCH] avoid infinite remote search --- .../src/search/context.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/react-bootstrap-table2-toolkit/src/search/context.js b/packages/react-bootstrap-table2-toolkit/src/search/context.js index 67935bf..c579999 100644 --- a/packages/react-bootstrap-table2-toolkit/src/search/context.js +++ b/packages/react-bootstrap-table2-toolkit/src/search/context.js @@ -20,11 +20,26 @@ export default (options = { searchText: PropTypes.string } + constructor(props) { + super(props); + this.performRemoteSearch = props.searchText !== ''; + } + + componentWillReceiveProps(nextProps) { + if (isRemoteSearch()) { + if (nextProps.searchText !== this.props.searchText) { + this.performRemoteSearch = true; + } else { + this.performRemoteSearch = false; + } + } + } + search() { const { data, columns } = this.props; let { searchText } = this.props; - if (isRemoteSearch()) { + if (isRemoteSearch() && this.performRemoteSearch) { handleRemoteSearchChange(searchText); return data; }