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
{{ message }}
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
Currently, the store state is initialized once (during hydration). However, when client-side navigation happens, it could contain newly defined state for the new HTML that should not be ignored.
We need to read and merge the new state into the current state, keeping the props it already has.
The text was updated successfully, but these errors were encountered:
To document here how to deal with this state merge:
If the state should be updated after client-side navigation, the developer won't have to do anything because it will be the default behavior.
For example, imagine there is a state.myPlugin.pageLikes property with the number of likes of a certain page. That number will come populated from the server, and can be updated if the user clicks on the "Like" button. When the user navigates to another page, the state.myPlugin.pageLikes property must be replaced with the number of likes of the new page, populated again from the server.
If the state should not be updated after client-side navigation, the developer needs to create an additional property that is only present on the client (and therefore it won't be updated).
For example, imagine a state.myPlugin.input property that populates an input and differs depending on each page. Users can edit the input; the input value should not change when they navigate to another page.
In this case, the recommendation would be to rename the property to state.myPlugin.initialInput, and use it to populate a client-only state.myPlugin.input that won't be updated when both states are merged.
Currently, the store state is initialized once (during hydration). However, when client-side navigation happens, it could contain newly defined state for the new HTML that should not be ignored.
We need to read and merge the new state into the current state, keeping the props it already has.
The text was updated successfully, but these errors were encountered: