Skip to content
Myr

Persisting store doc href hash fixes and tweaks (#1398)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* chore(docs): Fix casing in Persist middleware docs * docs: Remove unhelpful 'see below' and make other more helpful * docs: Remove link incompatible between GH & Docs site.

authored by Will McBride · committed by GitHub · parent c2248fd · Browse files · 1 file+3 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−6 removed

  • other:+3 added−6 removed

1 file+3 added−6 removed

modified:docs/integrations/persisting-store-data.md+3 added-6 removed
4 unmodified lines
56The persist middleware enables you to store your Zustand state in a storage (e.g. `localStorage`, `AsyncStorage`, `IndexedDB`, etc...) thus persisting it's data.78Note that this middleware does support both synchronous storages (e.g. `localStorage`) and asynchronous storages (e.g. `AsyncStorage`), but using an asynchronous storage does come with a cost.9See [Hydration and asynchronous storages](#Hydration-and-asynchronous-storages) for more details.9See [Hydration and asynchronous storages](#hydration-and-asynchronous-storages) for more details.1011Quick example:1213```ts
13 unmodified lines
27 )28)29```3031See [Options](#Options) for more details.3231## Options3233### `name`34
168 unmodified lines
203> Default: `0`204205If you want to introduce a breaking change in your storage (e.g. renaming a field), you can specify a new version number.206By default, if the version in the storage does not match the version in the code, the stored value won't be used.207You can use the `migrate` option to handle breaking changes in order to persist previously stored data.208210See the `migrate` option below for more details about handling breaking changes.211209### `migrate`210211> Schema: `(persistedState: Object, version: number) => Object | Promise<Object>`212
195 unmodified lines
408Why does it matter?409Asynchronous hydration can cause some unexpected behaviors.410For instance, if you use Zustand in a React app, the store will _not_ be hydrated at the initial render. In cases where you app depends on the persisted value at page load, you might want to wait until the store has been hydrated before showing anything (e.g. your app might think the user is not logged in because it's the default, while in reality the store has not been hydrated yet).411415If your app does depends on the persisted state at page load, see [How can I check if my store has been hydrated?](#how-can-I-check-if-my-store-has-been-hydrated) in the Q/A.412If your app does depends on the persisted state at page load, see **_How can I check if my store has been hydrated?_** in the Q/A section.413414## Q/A415416### How can I check if my store has been hydrated?
155 unmodified lines