Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use existing parameter
  • Loading branch information
adamwathan committed Feb 13, 2019
commit 2342d72c5e331bc052d507d6acb55d92d24ab663
7 changes: 3 additions & 4 deletions src/util/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import mergeWith from 'lodash/mergeWith'
import isFunction from 'lodash/isFunction'
import defaults from 'lodash/defaults'
import map from 'lodash/map'
import get from 'lodash/get'

function resolveFunctionKeys(object) {
return Object.keys(object).reduce((resolved, key) => {
Expand All @@ -18,15 +17,15 @@ function without(object, key) {
}

function mergeExtensions(theme) {
return mergeWith({}, without(theme, 'extend'), theme.extend, (_, value, key) => {
return mergeWith({}, without(theme, 'extend'), theme.extend, (_, extensions, key) => {
Copy link

@ramon-villain ramon-villain Feb 14, 2019

Choose a reason for hiding this comment

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

Would not you get the same result spreading the parameter?

function mergeExtensions({extend, ...theme}) {
  return mergeWith({}, theme, extend, (_, extensions, key) => {

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, so much better, thanks! ❤️

return isFunction(theme[key])
? mergedTheme => ({
...theme[key](mergedTheme),
...get(theme.extend, key, {})
...extensions
})
: {
...theme[key],
...get(theme.extend, key, {}),
...extensions,
}
})
}
Expand Down