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.

Hook is not triggered when boolean property changed on nested object.

See original GitHub issue
  • use-deep-compare-effect version:1.3.0
  • node version: 12.9.1
  • npm (or yarn) version: 6.4.1

What you did: Passed an object (nested) as prop to a functional component

What happened: One of the nested properties of the object is changed from false/true.

Problem description: useDeepEffect is not triggered when object changed.

Suggested solution: the only way I manage to achieve what I wanted is to by doing: JSON.stringify(nestedObject)

Object Structure:

nestedObject: {
 a: {another obj},
 array: [
         {b: Boolean},
         {c: Boolean},
         {d: Boolean},
       ]
}

Problem: Boolean ‘C’ changed, but useDeepEffect is not triggered.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
niamleesoncommented, Feb 13, 2020

@trentonsnyder That sandbox is setting a new object reference on button click so it seems like it is working correctly. Here’s an actual reproduction of the bug: https://codesandbox.io/s/restless-star-c175j

0reactions
MadhuvanthGcommented, May 29, 2020

https://github.com/kentcdodds/use-deep-compare-effect/blob/master/src/__tests__/index.js#L82-L95

this may be useful in the future, but we don’t support it today so I thought it’d be good to include as a test as it would be a breaking change if we did add support. I’m inclined to not support this. Manipulation is not good.

Ok, this sums it up, I think. Intentionally not supported and it makes sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React hook toggle bool value on nested property
I create an initial state with a boolean for whether the modal will show or not, and an additional property to pass in...
Read more >
TIL: You can watch for nested properties changing in React's ...
Today I learned: you can watch for nested properties changing in React's useEffect() hook by using dot notation in the dependency array, ...
Read more >
SyntheticEvent - React
React normalizes events so that they have consistent properties across different browsers. The event handlers below are triggered by an event in the...
Read more >
Reactivity Fundamentals - Vue.js
However, properties added this way will not be able to trigger reactive updates. ... changes to be detected even when you mutate nested...
Read more >
renderedCallback() in Lightning Web Component
A lifecycle hook is a callback method triggered at a specific phase ... is do not use renderedCallback() to change the state of...
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