Comments (11)
Fixed in [email protected]
from react-fast-compare.
Hi @NMinhNguyen -- we'll look into taking the proposed fix and tests directly when we have a chance (maybe next week?)
from react-fast-compare.
#123 is up for review if anyone wants to kick the tires on it?
from react-fast-compare.
If you're using yarn
, just checkout this git repo and then yarn link the repo in your project.
Or, worst case just manually replace index.js
from this project in your node_modules/react-fast-compare/
😂
from react-fast-compare.
One more note about behavior here which is now called out in the tests:
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects
{
description: 'Object.create(null) equal to vanilla null prototype deep objects',
value1: Object.assign(Object.create(null), { a: 1, b: { c: true } }),
value2: { __proto__: null, a: 1, b: { c: true } },
equal: true
},
// Object.create(null) has a different `constructor` than a vanilla, non-null object.
{
description: 'Object.create(null) unequal to vanilla deep objects',
value1: Object.assign(Object.create(null), { a: 1, b: { c: true } }),
value2: { a: 1, b: { c: true } },
equal: false
},
Namely, Object.create(null)
has a different .constructor
field than a normal non-null object. I think this is the correct approach for the library, but we could open it up to discussion -- I think the cases in which two objects are created and compared but coming from different original sources (non-null vs null) should be rare. I think "not blowing up" on null prototype should be the focus. And in our case, the library errs to default on the side of returning false
which may be incorrect, while true
should always be correct in terms of usage behavior...
from react-fast-compare.
Upstream issue in fast-deep-equal
: epoberezkin/fast-deep-equal#49
from react-fast-compare.
Just checking in on this - fast-deep-equal
is still at v3.1.1, so the fix has not yet been introduced.
from react-fast-compare.
Hey, I do realise that this PR hasn't been merged upstream, but do you have any objections to applying this diff to react-fast-compare
? https://github.com/epoberezkin/fast-deep-equal/pull/134/files#diff-443d5464f90756fa4d7b70e3b5232f7b86ddeeca5d98581a0450a6ce08033e0d
from react-fast-compare.
Hi @NMinhNguyen -- we'll look into taking the proposed fix and tests directly when we have a chance (maybe next week?)
Sure, no rush! Thank you for getting back to me :) My main hesitation with raising a PR was that I'm not sure if there's any significant performance impact from the additional typeof
checks. That being said, perhaps not throwing errors is more important.
from react-fast-compare.
#123 is up for review if anyone wants to kick the tires on it?
Thank you so much for this! What's the best way to do so? By patching the dependency with the diff from the PR?
from react-fast-compare.
If you're using
yarn
, just checkout this git repo and then yarn link the repo in your project.Or, worst case just manually replace
index.js
from this project in yournode_modules/react-fast-compare/
😂
@ryan-roemer can confirm it's working now :) thanks once again!
from react-fast-compare.
Related Issues (20)
- Upgrade dependencies
- Add ability to compare functions HOT 9
- module '/node_modules/react-fast-compare/index.js' does not provide an export HOT 1
- Handle anonymous function HOT 2
- Bug: Set compares by reference not value HOT 6
- TypeScript library for react-fast-compare? HOT 9
- Fix exported types so that they work for react-redux HOT 8
- Getters are not considered HOT 2
- IE 11: Object doesn't support property or method 'isView' HOT 26
- There should be a 'debug' feature to determine which fields are breaking equality.
- Types: documentation, clean up, and testing
- Audit security alerts HOT 2
- Fix benchmark chart img path
- Ignore Arrow Functions HOT 1
- Re-evaluate project's eslint rules HOT 1
- Update benchmark png HOT 2
- CJS + ESM Question/discussion HOT 6
- Differences in objects with properties that are associative arrays are not detected HOT 8
- Infra: Switch to GitHub Actions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-fast-compare.