-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Regression: Component conditionally rendered on query parameter fails to update hook value from null to non-null #702
Comments
Ah I thought this could come back up when I was refactoring for v2, but the test that covered it before passed. I believe the issue was that we need to take the value from the update queue into account when reading the initial search params for the internal state. There was an issue for this, let me dig around and I'll come back to you. Edit: yes it was #359. So maybe the test isn't going far enough. |
Could you try this and let me know if it fixes your problem please?
|
Seems to be fixed! Thank you so much once again for your super swift response. |
Cool, I'll find a way to properly test this to prevent regressions and I'll publish a release tomorrow. |
🎉 This issue has been resolved in version 2.0.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Context
What's your version of
nuqs
?What framework are you using?
Which version of your framework are you using?
Description
After upgrading to
[email protected]
(from[email protected]
), a regression appeared where changing a query parameter fromnull
to any value does not trigger an update to the value stored inuseQueryState(s)
if the component that calls the hook is rendered conditionally. The hook returnsnull
on initial change of the query parameter fromnull
to a value, and starts behaving as expected only after subsequent changes to the query parameter.Reproduction
Custom query parameter hook:
The main component:
The child component:
There exists a separate component with a list of cards in which pressing on a card changes the
itemId
value to a specific string:When no value is selected, pressing on the first button changes the URL appropriately, but
<ChildComponent />
does not register thatitemId
is set to"value1"
; it continues to returnnull
. However, whileitemId
is"value1"
, a subsequent click on the second button changes the URL appropriately once again, and now<ChildComponent />
is able to register the query value as"value2"
.Removing the conditional render of
<ChildComponent />
makes the issue go away. This bug does not appear in the version ofnuqs
prior to version 2.The text was updated successfully, but these errors were encountered: