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

Query doesn't update with custom stringify and parse using nested object #328

Closed
donnysim opened this issue Jun 24, 2020 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@donnysim
Copy link

Version

4.0.0-alpha.13

Reproduction link

https://codesandbox.io/s/silent-architecture-htfrf

Steps to reproduce

Click "Page 1", click "Page 2".

What is expected?

After clicking "Page 2" the query should update.

What is actually happening?

The query is stuck on "Page 1"


This probably has something to do with nested query params? changing destination to { query: { users: 1 } } works as expected.

@posva posva added the bug Something isn't working label Jun 24, 2020
@posva
Copy link
Member

posva commented Jun 24, 2020

Nested objects are not checked right now. I think it will make more sense to check the string representation of the query although this means different orders will still create a new navigation

@donnysim
Copy link
Author

donnysim commented Jun 24, 2020

I don't think that would be bad, though I guess it could impact the "exact" route if it also check the queries. Unless maybe there could be an option where we can compare the values ourselves to decide if they differ? Kind of feel string value could also be impacted by the way the query is encoded.

I always used queries kind of in a different way where each component specifies what query parameters it cares about, validation rule for them, type, default etc.. and it triggers separate "queryChanged" callback when they do change, so in my case it would not make a difference as I'm not watching route change, but rather query change and route props if necessary, though it's also single level only so while I was experimenting with nested approach where each parameter is a custom formatted json in url and I stumbled upon this.

@posva posva closed this as completed in 6e1f0ea Jun 24, 2020
@posva
Copy link
Member

posva commented Jun 24, 2020

The active link behavior changed and queries and hashes are not taken into account anymore

@donnysim
Copy link
Author

donnysim commented Jun 25, 2020

@posva it still doesn't work, normalizeQuery converts { users: { page: 1 } } to { users: '[object Object]' } and it fails to pass or diff? in isSameRouteLocation. Though weirdly it only happens on second navigation.

@posva
Copy link
Member

posva commented Jun 25, 2020

I removed the normalizeQuery call when a stringifyQuery option is passed

@donnysim
Copy link
Author

Seems good now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants