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

Commit

Permalink
fix: use lodash version of unsupported Array.{fill, find} (#1118)
Browse files Browse the repository at this point in the history
* fix(createInstantSearchManager): use lodash find instead of native one

* fix(createConnector): use lodash find instead of native one

* fix(RatingMenu): use lodash find instead of native one

* fix(RatingMenu): use lodash fill instead of native one
  • Loading branch information
samouss authored Mar 28, 2018
1 parent c7e7922 commit ea7bf42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/react-instantsearch/src/components/RatingMenu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { find, fill } from 'lodash';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand Down Expand Up @@ -144,10 +145,9 @@ class RatingMenu extends Component {
.map(item => ({ ...item, value: parseFloat(item.value) }))
.filter(item => item.value >= limitMin && item.value <= limitMax);

const range = new Array(safeInclusiveLength)
.fill(null)
const range = fill(new Array(safeInclusiveLength), null)
.map((_, index) => {
const element = values.find(item => item.value === limitMax - index);
const element = find(values, item => item.value === limitMax - index);
const placeholder = { value: limitMax - index, count: 0, total: 0 };

return element || placeholder;
Expand Down
5 changes: 3 additions & 2 deletions packages/react-instantsearch/src/core/createConnector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { has, isEqual } from 'lodash';
import { has, isEqual, find } from 'lodash';
import { shallowEqual, getDisplayName, removeEmptyKey } from './utils';

/**
Expand Down Expand Up @@ -82,7 +82,8 @@ export default function createConnector(connectorDesc) {
this.unregisterWidget = widgetsManager.registerWidget(this);
}
if (process.env.NODE_ENV === 'development') {
const onlyGetProvidedPropsUsage = !Object.keys(connectorDesc).find(
const onlyGetProvidedPropsUsage = !find(
Object.keys(connectorDesc),
key =>
[
'getMetadata',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { omit, isEmpty } from 'lodash';
import { omit, isEmpty, find } from 'lodash';
import algoliasearchHelper, { SearchParameters } from 'algoliasearch-helper';
import createWidgetsManager from './createWidgetsManager';
import createStore from './createStore';
Expand Down Expand Up @@ -101,7 +101,7 @@ export default function createInstantSearchManager({
const targetedIndex = widget.context.multiIndexContext
? widget.context.multiIndexContext.targetedIndex
: widget.props.indexName;
const index = indices.find(i => i.targetedIndex === targetedIndex);
const index = find(indices, i => i.targetedIndex === targetedIndex);
if (index) {
index.widgets.push(widget);
} else {
Expand Down

0 comments on commit ea7bf42

Please sign in to comment.