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.

Connector should use deepEqual

See original GitHub issue

I have been hunting a bug that turns out to have been caused by the fact that Connector shallowly compares the current slice to the next. The diffs buried deep in a slice doesn’t trigger updates in the connected components because of this. For example:

Before:

{
   MapReducer: {
      layers: []
   }
}

After:

{
   MapReducer: {
      layers: [{id: 1, name: 'my-layer'}]
   }
}

…no updates.

I know I can do @connect(state => state.MapReducer) but I also want the component to receive the state from other reducers. Any tips for me?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jul 27, 2015

For example

function (state, action) {
  state.xxx = yyy;
}

is wrong,

// ES6
function (state, action) {
  return Object.assign({}, state, { xxx: yyy });
}

// ES7 spread syntax
function (state, action) {
  return { ...state, xxx: yyy );
}

is correct.

0reactions
gaearoncommented, Jul 28, 2015

No problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

nodejs deep equal with differences - unit testing - Stack Overflow
I've tried should, when I compare two different object it just tells me "Error: AssertionError: expected {....} to equal {....}" without showing me...
Read more >
Going Deep with XS: deepEqual and structuredClone
Node.js provides deepEqual assertions to perform deep comparison of ... Using deepEqual and structuredClone in your projects is easy.
Read more >
fast-deep-equal - NPM Package Overview - Socket.dev
Start using Socket to analyze fast-deep-equal and its 0 dependencies to secure your app ... Tidelift will coordinate the fix and disclosure.
Read more >
NuGet Gems: DeepEqual - Nicola Iarocci
An extensible deep comparison library for .NET. I am sure you too have come across this a few times. You have some code...
Read more >
Gomega is a matcher
DeepEqual is awesome. It will use == when appropriate (e.g. when comparing primitives) but will recursively dig into maps, slices, arrays, and even...
Read more >

github_iconTop Related Medium Post

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