fix(trim query before search)

This commit is contained in:
shakti97 2020-04-06 09:21:09 +05:30
parent 5a79a84833
commit ebe53c83f9

View file

@ -26,12 +26,13 @@ class Searchbar extends React.Component {
handleSearchEnter = (e) => { handleSearchEnter = (e) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
this.props.setSearchTerm(this.state.searchValue); this.searchChange();
} }
} }
searchChange = (value) => { searchChange = () => {
this.props.setSearchTerm(this.state.searchValue); if (this.state.searchValue.trim().length === 0) return;
this.props.setSearchTerm(this.state.searchValue.trim());
}; };
handleSearchChange = (e) => { handleSearchChange = (e) => {