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

Commit

Permalink
refactor(lodash): pick (#2432)
Browse files Browse the repository at this point in the history
* refactor(lodash): pick

replaced by destructuring

* chore: remove isEmpty variable
  • Loading branch information
Haroenv committed May 13, 2019
1 parent c0e150b commit f170609
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 37 deletions.
27 changes: 16 additions & 11 deletions packages/react-instantsearch-dom/src/components/HierarchicalMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { pick } from 'lodash';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { translatable } from 'react-instantsearch-core';
Expand Down Expand Up @@ -51,20 +50,26 @@ class HierarchicalMenu extends Component {
};

render() {
const {
translate,
items,
showMore,
limit,
showMoreLimit,
canRefine,
className,
} = this.props;
return (
<List
renderItem={this.renderItem}
cx={cx}
{...pick(this.props, [
'translate',
'items',
'showMore',
'limit',
'showMoreLimit',
'isEmpty',
'canRefine',
'className',
])}
translate={translate}
items={items}
showMore={showMore}
limit={limit}
showMoreLimit={showMoreLimit}
canRefine={canRefine}
className={className}
/>
);
}
Expand Down
35 changes: 22 additions & 13 deletions packages/react-instantsearch-dom/src/components/Menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { pick } from 'lodash';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { translatable } from 'react-instantsearch-core';
Expand Down Expand Up @@ -62,23 +61,33 @@ class Menu extends Component {
};

render() {
const {
translate,
items,
showMore,
limit,
showMoreLimit,
isFromSearch,
searchForItems,
searchable,
canRefine,
className,
} = this.props;
return (
<List
renderItem={this.renderItem}
selectItem={this.selectItem}
cx={cx}
{...pick(this.props, [
'translate',
'items',
'showMore',
'limit',
'showMoreLimit',
'isFromSearch',
'searchForItems',
'searchable',
'canRefine',
'className',
])}
translate={translate}
items={items}
showMore={showMore}
limit={limit}
showMoreLimit={showMoreLimit}
isFromSearch={isFromSearch}
searchForItems={searchForItems}
searchable={searchable}
canRefine={canRefine}
className={className}
/>
);
}
Expand Down
35 changes: 22 additions & 13 deletions packages/react-instantsearch-dom/src/components/RefinementList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { pick } from 'lodash';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { translatable } from 'react-instantsearch-core';
Expand Down Expand Up @@ -67,23 +66,33 @@ class RefinementList extends Component {
};

render() {
const {
translate,
items,
showMore,
limit,
showMoreLimit,
isFromSearch,
searchForItems,
searchable,
canRefine,
className,
} = this.props;
return (
<List
renderItem={this.renderItem}
selectItem={this.selectItem}
cx={cx}
{...pick(this.props, [
'translate',
'items',
'showMore',
'limit',
'showMoreLimit',
'isFromSearch',
'searchForItems',
'searchable',
'canRefine',
'className',
])}
translate={translate}
items={items}
showMore={showMore}
limit={limit}
showMoreLimit={showMoreLimit}
isFromSearch={isFromSearch}
searchForItems={searchForItems}
searchable={searchable}
canRefine={canRefine}
className={className}
query={this.state.query}
/>
);
Expand Down

0 comments on commit f170609

Please sign in to comment.