Skip to content

Do a proper check for object equality #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

rmacqueen
Copy link

Previously we were just using a simple '==' to check if
new defaultCenter was equal to old defaultCenter. However,
defaultCenter is an object, and therefore '==' will always
return false unless they reference the same object in memory.
Instead we should do a proper comparison of the properties
of the object.

Previously we were just using a simple '==' to check if
new defaultCenter was equal to old defaultCenter. However,
defaultCenter is an object, and therefore '==' will always
return false unless they reference the same object in memory.
Instead we should do a proper comparison of the properties
of the object.
Copy link
Member

@itsmichaeldiego itsmichaeldiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix travis errors here

@@ -0,0 +1,25 @@
export default function areObjectsEqual(a, b) {
// Create arrays of property names
var aProps = Object.getOwnPropertyNames(a);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use const or let instead of var.

@itsmichaeldiego
Copy link
Member

itsmichaeldiego commented Mar 14, 2018

@rmacqueen As you did not answer I handled this using facebook's shallowEquals method. PR #540

@rmacqueen
Copy link
Author

@itsmichaeldiego oops, sorry didn't see this. What you did works though. Thanks!

@lock
Copy link

lock bot commented Dec 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants