question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"skipping autoRehydrate" throw for nested Object and Array

See original GitHub issue

I try to mix redux-persist with https://github.com/omnidan/redux-undo for fun but what I found so far is when I have nested object array (generated by undoredo), autoRehydrate will refuse to work.

screen shot 2016-10-17 at 00 33 40

And that because https://github.com/rt2zz/redux-persist/blob/master/src/autoRehydrate.js#L61 compare…

    if (state[key] !== reducedState[key]) {

which…

state[key]: Object {past: Array[0], present: Array[0], future: Array[0], history: Object}
reducedState[key]: Object {past: Array[0], present: Array[0], future: Array[0], history: Object}

is (kinda) same (blank) value but (obviously) different object so it didn’t equal anyway.

Any hint to make it work?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsernstcommented, Dec 9, 2016

I was able to get around this problem by adjusting my reducer to clone the array, instead of just directly modifying its values.

This reducer was being ignored by autoRehydrate:

    case 'ADJUST_SCORE': {
      const updatedPeople = state.people
      updatedPeople[action.rowIndex].score = action.score

      return { ...state,
        people: updatedPeople,
      }
    }

Fixed:

    case 'ADJUST_SCORE': {
-     const updatedPeople = state.people
+     const updatedPeople = [...state.people]
      updatedPeople[action.rowIndex].score = action.score

      return { ...state,
        people: updatedPeople,
      }
    }

Hope this helps ✌️👍

0reactions
aguynamedbencommented, Dec 22, 2018

This hasn’t been responded to in a long while, so I’m going to mark it as stale. Please feel free to continue the conversation and I’ll reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you skip a level in a nested object without knowing the ...
I want to remove or and skip through directly to the children. But it is a random produced key value "between". How can...
Read more >
Accessing Nested Objects in JavaScript - DEV Community ‍ ‍
Array reduce method is very powerful and it can be used to safely access nested objects. const getNestedObject = (nestedObj, pathArr) = ...
Read more >
Using ES6 To Destructure Deeply Nested Objects in ... - ITNEXT
Today, I will show you how to use ES6 to destructure nested objects, my friends, AND what's more, prevent the dreaded undefined error...
Read more >
Archie Markup Language (ArchieML) 1.0
Nested arrays can be either Object or String arrays, using the same rules as top-level arrays for determining the type. Only object arrays...
Read more >
Heres how JavaScript's Nested Object Destructuring works
A quick video detailing how destructuring works with nested objects and arrays. Check out my https://ES6.io course for more!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found