docs: fix document error of persist with hydration (#1758)

* docs: fix document error of persist with hydration

* Update persisting-store-data.md

* Apply suggestions from code review

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update persisting-store-data.md

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
This commit is contained in:
Arvin Xu 2023-04-18 17:49:56 +08:00 committed by GitHub
parent df38aa8c5a
commit a999f7ac04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,7 +273,7 @@ In some applications you may need to control when the first hydration occurs.
For example, in server-rendered apps.
If you set `skipHydration`, the initial call for hydration isn't called,
and it is left up to you to manually call `reHydrate()`.
and it is left up to you to manually call `rehydrate()`.
```ts
export const useBoundStore = create(
@ -291,12 +291,12 @@ export const useBoundStore = create(
```
```tsx
export function StoreConsumer(){
const store = useBoundStore();
import { useBoundStore } from './path-to-store';
export function StoreConsumer() {
// hydrate persisted store after on mount
useEffect(() => {
store.persist.reHydrate();
useBoundStore.persist.rehydrate();
}, [])
return (