Skip to content

Commit c98aebb

Browse files
author
Luke Westby
committed
import directly from inner lodash modules instead of loading all of lodash
1 parent bb9ebdc commit c98aebb

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/extendReactClass.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import linkClass from './linkClass';
22
import React from 'react';
3-
import _ from 'lodash';
3+
import isObject from 'lodash/lang/isObject';
4+
import assign from 'lodash/object/assign';
45

56
let extendReactClass;
67

@@ -18,8 +19,8 @@ extendReactClass = (Component, defaultStyles, options) => {
1819

1920
if (this.props.styles) {
2021
styles = this.props.styles;
21-
} else if (_.isObject(defaultStyles)) {
22-
this.props = _.assign({}, this.props, {
22+
} else if (isObject(defaultStyles)) {
23+
this.props = assign({}, this.props, {
2324
styles: defaultStyles
2425
});
2526

src/linkClass.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import makeConfiguration from './makeConfiguration';
3-
import _ from 'lodash';
3+
import filter from 'lodash/collection/filter';
4+
import isArray from 'lodash/lang/isArray';
45

56
let linkClass;
67

@@ -29,7 +30,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
2930

3031
if (styleNames) {
3132
styleNames = styleNames.split(' ');
32-
styleNames = _.filter(styleNames);
33+
styleNames = filter(styleNames);
3334

3435
if (configuration.allowMultiple === false && styleNames.length > 1) {
3536
throw new Error(`ReactElement styleName property defines multiple module names ("${element.props.styleName}").`);
@@ -64,7 +65,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
6465

6566
if (React.isValidElement(element.props.children)) {
6667
newChildren = linkClass(React.Children.only(element.props.children), styles, configuration);
67-
} else if (_.isArray(element.props.children)) {
68+
} else if (isArray(element.props.children)) {
6869
newChildren = React.Children.map(element.props.children, (node) => {
6970
if (React.isValidElement(node)) {
7071
return linkClass(node, styles, configuration);

src/makeConfiguration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import forEach from 'lodash/collection/forEach';
22

33
/**
44
* @typedef CSSModules~Options
@@ -19,7 +19,7 @@ export default (userConfiguration = {}) => {
1919
errorWhenNotFound: true
2020
};
2121

22-
_.forEach(userConfiguration, (value, name) => {
22+
forEach(userConfiguration, (value, name) => {
2323
if (typeof configuration[name] === 'undefined') {
2424
throw new Error(`Unknown configuration property "${name}".`);
2525
}

src/wrapStatelessFunction.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import linkClass from './linkClass';
22
import React from 'react';
3-
import _ from 'lodash';
3+
import assign from 'lodash/object/assign';
4+
import isObject from 'lodash/lang/isObject';
45

56
let wrapStatelessFunction;
67

@@ -22,8 +23,8 @@ wrapStatelessFunction = (Component, defaultStyles, options) => {
2223
if (props.styles) {
2324
useProps = props;
2425
styles = props.styles;
25-
} else if (_.isObject(defaultStyles)) {
26-
useProps = _.assign({}, props, {
26+
} else if (isObject(defaultStyles)) {
27+
useProps = assign({}, props, {
2728
styles: defaultStyles
2829
});
2930

@@ -42,7 +43,7 @@ wrapStatelessFunction = (Component, defaultStyles, options) => {
4243
return React.createElement('noscript');
4344
};
4445

45-
_.assign(WrappedComponent, Component);
46+
assign(WrappedComponent, Component);
4647

4748
return WrappedComponent;
4849
};

0 commit comments

Comments
 (0)