Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
refactor(lodash): isEmpty
Browse files Browse the repository at this point in the history
reusing objectHasKeys strategy from the helper

IFW-736
  • Loading branch information
Haroenv committed May 15, 2019
1 parent cedf564 commit 559aa4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty } from 'lodash';
import { objectHasKeys } from '../core/utils';
import createConnector from '../core/createConnector';
import {
getResults,
Expand Down Expand Up @@ -73,7 +73,7 @@ const getCurrentRefinement = (props, searchState, context) => {
{}
);

if (isEmpty(refinement)) {
if (!objectHasKeys(refinement)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { find, isEmpty } from 'lodash';
import { find } from 'lodash';
import PropTypes from 'prop-types';
import { objectHasKeys } from '../core/utils';
import createConnector from '../core/createConnector';
import {
cleanUpValue,
Expand Down Expand Up @@ -156,7 +157,7 @@ export default createConnector({
if (!items.some(item => item.value === '')) {
items.push({
value: '',
isRefined: isEmpty(refinedItem),
isRefined: !objectHasKeys(refinedItem),
noRefinement: !stats,
label: 'All',
});
Expand Down
4 changes: 4 additions & 0 deletions packages/react-instantsearch-core/src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ export function addQueryID(hits, queryID) {
__queryID: queryID,
}));
}

export function objectHasKeys(object) {
return object && Object.keys(object).length > 0;
}

0 comments on commit 559aa4f

Please sign in to comment.