diff --git a/src/reconciler/proxies.js b/src/reconciler/proxies.js index b3681da73..e3deb3019 100644 --- a/src/reconciler/proxies.js +++ b/src/reconciler/proxies.js @@ -3,8 +3,7 @@ import { resetClassProxies } from '../proxy/createClassProxy'; import { isCompositeComponent, isReactClass } from '../internal/reactUtils'; import configuration from '../configuration'; import { incrementHotGeneration } from '../global/generation'; - -const merge = require('lodash/merge'); +import { merge } from './utils'; let signatures; let proxiesByID; diff --git a/src/reconciler/utils.js b/src/reconciler/utils.js index 0e0df896c..fb1468ad7 100644 --- a/src/reconciler/utils.js +++ b/src/reconciler/utils.js @@ -74,3 +74,25 @@ export const areSwappable = (a, b) => { } return false; }; + +export function merge(...sources) { + let acc = {}; + for (const source of sources) { + if (source instanceof Array) { + if (!(acc instanceof Array)) { + acc = []; + } + acc = [...acc, ...source]; + } else if (source instanceof Object) { + for (const entry of Object.entries(source)) { + const key = entry[0]; + let value = entry[1]; + if (value instanceof Object && key in acc) { + value = merge(acc[key], value); + } + acc = { ...acc, [key]: value }; + } + } + } + return acc; +}