You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A user on Discord brought up an interesting issue when building pagination:
i tried to go off of the pagination implemented in the create-hydrogen-app and it seems that the numProducts state isn't being reset when switching between categories - thus resulting in loading numProducts + default number products on every category.
Is there a simple way to reset the server state if handle changes or something? not sure the "proper" way this could be achieved.
The problem here is that we use serverState for both routing and custom uses.
Routing uses pathname and search and is meant to be tied to a given route, fairly opaque to the developer, and persisted for new navigations
Custom state is whatever the developer decides to set, like pagination values. This should be cleared between page navigations
There is a third type of state, like a "permanent custom" state, which could serve as something that ought to remain for the duration of the browser session. Imagine a locale preference, a dark mode toggle, etc.
So perhaps to support this, we need to split serverState into two buckets: permanent and ephemeral? (but the API needs to not be named those gross things).
Is there another way to approach this?
The text was updated successfully, but these errors were encountered:
Another potential API: We could start by changing the type of serverState from string to string | {value: string; permanent: boolean} where users can optionally specify the lifespan of the state (when to reset). It is a non-breaking change.
We should gather more use cases though, I'm not sure of how fine-grained control we need to expose. A more complex API could be a dependencies Array that tigger state refreshes.
Describe the bug
A user on Discord brought up an interesting issue when building pagination:
The problem here is that we use
serverState
for both routing and custom uses.pathname
andsearch
and is meant to be tied to a given route, fairly opaque to the developer, and persisted for new navigationsSo perhaps to support this, we need to split
serverState
into two buckets:permanent
andephemeral
? (but the API needs to not be named those gross things).Is there another way to approach this?
The text was updated successfully, but these errors were encountered: