Skip to content

Commit 44746ac

Browse files
le0nikgajus
authored andcommitted
perf: optimize linkArray by replacing elements in original array (gajus#244)
1 parent b51b1f3 commit 44746ac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/linkClass.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ const mapChildrenWithoutKeyPrefix = (children: ReactElement, mapper: Function, c
2222
};
2323

2424
const linkArray = (array: Array, styles: Object, configuration: Object) => {
25-
return _.map(array, (value) => {
25+
_.forEach(array, (value, index) => {
2626
if (React.isValidElement(value)) {
2727
// eslint-disable-next-line no-use-before-define
28-
return linkElement(React.Children.only(value), styles, configuration);
28+
array[index] = linkElement(React.Children.only(value), styles, configuration);
2929
} else if (_.isArray(value)) {
30-
return linkArray(value, styles, configuration);
30+
array[index] = linkArray(value, styles, configuration);
3131
}
32-
33-
return value;
3432
});
33+
34+
return array;
3535
};
3636

3737
const linkElement = (element: ReactElement, styles: Object, configuration: Object): ReactElement => {

0 commit comments

Comments
 (0)