FormidableLabs / react-fast-compare

fastest deep equal comparison for React
MIT License
1.59k stars 54 forks source link

add __v and __o keys to the custom handler to support Preact #67

Closed dios-david closed 4 years ago

dios-david commented 4 years ago

Hi there,

I'm using preact and I noticed this console warning in my browser: react-fast-compare cannot handle circular refs

After a bit of investigation I found out that one of my dependencies is using react-fast-compare which would work fine with preact as well after a minor modification. Instead of forking the project (e.g. preact-fast-compare) I thought it would be better to contribute to the project and make it work with both frameworks.

developit commented 4 years ago

Strong +1 from the Preact core team on this!

A suggestion: perhaps it would be worth ignoring all properties that have leading _? It'd be a more widespread change, but would also be a nice way to allow hiding properties from comparison that doesn't require defining them as non-enumerable.

dios-david commented 4 years ago

Yeah that sounds reasonable, I'm happy to make those changes if needed. I leave the decision up to the maintainers. @chrisbolin

chrisbolin commented 4 years ago

alright, current quick thoughts...

chrisbolin commented 4 years ago

oh also... i'm nervous about ignoring all _-prefixed properties: this could both be a regression for existing users AND cause new users some pain and confusion.

chrisbolin commented 4 years ago

just thinking ahead: when this is finished we should release as a minor version. I don't think it warrants a major release

kale-stew commented 4 years ago

Merging this into a feature branch so we can move forward with polishing up new Preact tests separate from your work, @dios-david. Thanks for introducing this feature. 🙌