Replacing lodash filter with native filter to avoid additional import (#2229)

@rmars and I set out to replace all instances of lodash filter with native
filter in order to prevent the additional import. However, there was only one
use of _filter that could be easily replaced, since our other uses depend on
lodash's ability to handle empty variables, and the ability to filter both
objects and arrays (JS's native filter is only for arrays). Switching to native
filter in those cases would have required us to manually check the value of the
variable, set it to an empty array and/or convert it from an object to an array.

Signed-off-by: Carol Scott <carol@buoyant.io>
This commit is contained in:
Carol A. Scott 2019-02-07 16:31:46 -08:00 committed by GitHub
parent 1ef25390ec
commit c38d323b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import _filter from 'lodash/filter';
import _get from 'lodash/get';
import _isEmpty from 'lodash/isEmpty';
import _merge from 'lodash/merge';
@ -48,9 +47,8 @@ const withREST = (WrappedComponent, componentPromises, options={}) => {
}
componentDidUpdate(prevProps) {
const changed = _filter(
localOptions.resetProps,
prop => _get(prevProps, prop) !== _get(this.props, prop),
const changed = localOptions.resetProps.filter(
prop => _get(prevProps, prop) !== _get(this.props, prop)
);
if (_isEmpty(changed)) { return; }