Skip to content
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

export a function for locations comparing #37

Closed
chentsulin opened this issue Sep 2, 2015 · 4 comments
Closed

export a function for locations comparing #37

chentsulin opened this issue Sep 2, 2015 · 4 comments

Comments

@chentsulin
Copy link

Does exists any functions can we compare equal between two locations?

Maybe should exist a function like this:

export function locationEquals(location1, location2) {
  if (location1 && location2 && location1.key && location2.key) {
    return location1.key === location2.key;
  }
  return false;
}
@mjackson
Copy link
Member

mjackson commented Sep 5, 2015

We already have a locationsAreEqual function, but that implementation is used specifically to determine whether or not the location has changed, which is slightly different. That function should probably be called locationHasChanged(prevLocation, nextLocation).

Is that what you need? What are you doing with it?

@chentsulin
Copy link
Author

I need a function to compare between a location in redux store's state and a location in routing context, so that I can sync them by dispatch a action on location change or transitionTo new location on state change.

@chentsulin
Copy link
Author

@mjackson
Copy link
Member

mjackson commented Oct 4, 2015

Just re-reading through your use case here.

When you get a new location in your redux dispatch, you can just call history.transitionTo(location) without worrying about whether or not the location is actually different. We already take care of that for you. So, let history worry about whether or not it actually needs to do something.

@mjackson mjackson closed this as completed Oct 4, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants