Skip to content

Commit

Permalink
only shallow merge plain objects
Browse files Browse the repository at this point in the history
  • Loading branch information
rt2zz committed Jan 28, 2016
1 parent 39dee2a commit 7dabb03
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/autoRehydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ module.exports = function autoRehydrate (config = {}) {
if (config.log) console.log('redux-persist/autoRehydrate action buffer released', queue)
}

function checkIsObject (data, reducedState, key) {
if (data.size || data.hasOwnProperty('size')) {
return true
} else if (reducedState[key] && (reducedState[key].size || reducedState[key].hasOwnProperty('size'))) {
return true
} else if (isPlainObject(data) || isPlainObject(reducedState[key])) {
return true
}
return false
}

function createRehydrationReducer (reducer) {
return (state, action) => {
if (action.type === REHYDRATE) {
Expand All @@ -46,8 +35,8 @@ module.exports = function autoRehydrate (config = {}) {
}

let autoReducedState = {...reducedState}
let isObject = checkIsObject(data, reducedState, key)
if (!isObject) {
let statesArePlain = isPlainObject(data) && isPlainObject(reducedState[key])
if (!statesArePlain) {
// assign value
autoReducedState[key] = data
} else {
Expand Down

0 comments on commit 7dabb03

Please sign in to comment.