Prevent unnecessary render - no need to clear search if already empty, just close dropdown

This commit is contained in:
A Lawliet
2017-06-22 10:29:41 -04:00
parent 91907e7647
commit c41b3c27ba
@@ -3,6 +3,7 @@ import {compose, gql} from 'react-apollo';
import StorySearch from '../components/StorySearch';
import {withRouter} from 'react-router';
import withQuery from 'coral-framework/hocs/withQuery';
import {isEmpty} from 'lodash';
class StorySearchContainer extends React.Component {
constructor(props) {
@@ -24,7 +25,9 @@ class StorySearchContainer extends React.Component {
}
clearAndCloseSearch = () => {
this.clearSearch();
if (!isEmpty(this.state.searchValue)) {
this.clearSearch();
}
this.props.closeSearch();
}