From 8d22532ab82dc39f6345511b62e6b6a41ae35dd3 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Mon, 17 Apr 2023 17:18:29 +0800 Subject: [PATCH 1/4] docs: fix document error of persist with hydration --- docs/integrations/persisting-store-data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/integrations/persisting-store-data.md b/docs/integrations/persisting-store-data.md index 22b45fbf71..4b36cf163c 100644 --- a/docs/integrations/persisting-store-data.md +++ b/docs/integrations/persisting-store-data.md @@ -291,9 +291,9 @@ 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(); From e25aeb780b804cc968c6b4d7d63a563de8c4fedb Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Mon, 17 Apr 2023 17:19:32 +0800 Subject: [PATCH 2/4] Update persisting-store-data.md --- docs/integrations/persisting-store-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations/persisting-store-data.md b/docs/integrations/persisting-store-data.md index 4b36cf163c..b4614b148f 100644 --- a/docs/integrations/persisting-store-data.md +++ b/docs/integrations/persisting-store-data.md @@ -296,7 +296,7 @@ import { useBoundStore } from './path-to-store'; export function StoreConsumer(){ // hydrate persisted store after on mount useEffect(() => { - store.persist.reHydrate(); + useBoundStore.persist.reHydrate(); }, []) return ( From 43aa0cd7fc59ed03f4875dad6341204587c9cb86 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Tue, 18 Apr 2023 17:38:53 +0800 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Blazej Sewera --- docs/integrations/persisting-store-data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/integrations/persisting-store-data.md b/docs/integrations/persisting-store-data.md index b4614b148f..aef21a32c3 100644 --- a/docs/integrations/persisting-store-data.md +++ b/docs/integrations/persisting-store-data.md @@ -293,10 +293,10 @@ export const useBoundStore = create( ```tsx import { useBoundStore } from './path-to-store'; -export function StoreConsumer(){ +export function StoreConsumer() { // hydrate persisted store after on mount useEffect(() => { - useBoundStore.persist.reHydrate(); + useBoundStore.persist.rehydrate(); }, []) return ( From 724b3a47c1128a09f04b949797aa51f7687271de Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Tue, 18 Apr 2023 17:40:11 +0800 Subject: [PATCH 4/4] Update persisting-store-data.md --- docs/integrations/persisting-store-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations/persisting-store-data.md b/docs/integrations/persisting-store-data.md index aef21a32c3..fac78b5a71 100644 --- a/docs/integrations/persisting-store-data.md +++ b/docs/integrations/persisting-store-data.md @@ -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(