fix: make sure the state-change effect runs for multi parsers#1163
fix: make sure the state-change effect runs for multi parsers#1163
Conversation
|
@TkDodo is attempting to deploy a commit to the 47ng Team on Vercel. A member of the Team first needs to authorize it. |
| Object.values(resolvedUrlKeys).map(urlKey => [ | ||
| urlKey, | ||
| initialSearchParams?.get(urlKey) ?? null | ||
| ]) | ||
| Object.entries(resolvedUrlKeys).map(([key, urlKey]) => { | ||
| const parser = keyMap[key] | ||
| return [ | ||
| urlKey, | ||
| parser?.type === 'multi' | ||
| ? initialSearchParams?.getAll(urlKey) | ||
| : (initialSearchParams?.get(urlKey) ?? null) | ||
| ] | ||
| }) |
There was a problem hiding this comment.
here, I’m trying to address a caching issue where we were putting the wrong values into the cachedQuery ( = queryRef.current) cache for multi parsers, because we were only reading the first search param with .get
Now, we are reading with .getAll for multi-parsers
@franky47 I’m not really sure how / where to add a test for this. I did add an e2e test for issue #1162
There was a problem hiding this comment.
Yeah the e2e test should be enough for this, thanks!
| Object.values(resolvedUrlKeys).map(urlKey => [ | ||
| urlKey, | ||
| initialSearchParams?.get(urlKey) ?? null | ||
| ]) | ||
| Object.entries(resolvedUrlKeys).map(([key, urlKey]) => { | ||
| const parser = keyMap[key] | ||
| return [ | ||
| urlKey, | ||
| parser?.type === 'multi' | ||
| ? initialSearchParams?.getAll(urlKey) | ||
| : (initialSearchParams?.get(urlKey) ?? null) | ||
| ] | ||
| }) |
There was a problem hiding this comment.
Yeah the e2e test should be enough for this, thanks!
commit: |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🎉 This PR is included in version 2.7.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fixes #1162
the dependency array of the state-change effect included stringified versions of searchParams, but it was always using
.get, which was only seeing the first search param.With multi-parsers, we need to look at all searchParams. It should be safe here to always call
.getAll(), because even for one key, this would be stable.