welldone-software / why-did-you-render

why-did-you-render by Welldone Software monkey patches React to notify you about potentially avoidable re-renders. (Works with React Native as well.)
https://www.npmjs.com/package/@welldone-software/why-did-you-render
MIT License
11.11k stars 196 forks source link

Objects are equal when saved to the console #253

Closed jcollum-nutrien closed 1 year ago

jcollum-nutrien commented 2 years ago

image

Process:

I was getting output from the tool that told me that the two objects were equal by value but not by ref. OK, so I save them both to globals. But they were equal by ref in that case: temp1 === temp2 // true (red line in screenshot)

But the diffs in the diffs array (which I saved to a global ref from the diffsAccumulator.push line while debugging the wdyr code) e.g. diffs[0].nextValue === diffs[0].prevValue say the two objects are not equal by ref (green line in screenshot)

The output is confusing if I get different results for equality when accessing the same objects from the console output vs the diffs array. I tried using a stringify (with a replace for circular refs, which could be the issue) and found that the two serialized values were identical.

This is a confusing result.

vzaidman commented 1 year ago

I need more context on this one. What is the tool outputting and what did you save? Can you please add more info to the screenshot or record a short clip?