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

fix: use lodash version of unsupported Array.{fill, find} #1118

Merged
merged 4 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to depend on /find and /fill ?

Copy link
Collaborator Author

@samouss samouss Mar 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The babel-plugin-lodash handle that for us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know we used it 🙌

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