From a932d794bdf7081fd9cabf86134cd251658f8b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20S=C3=B8rensen?= Date: Wed, 7 Aug 2024 14:42:08 +0200 Subject: [PATCH] Fix store-persistence example Calling `setHasHydrated` directly in `onRehydrateStorage` causes the state to only contain the `{ _hasHydrated: true }` rather than the actual hydrated state (which I believe will be lost). `setHasHydrated` must instead be called from the function returned from `onRehydrateStorage`, as that function will be called after the state has been hydrated. --- 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 92f201a287..8d63cc5726 100644 --- a/docs/integrations/persisting-store-data.md +++ b/docs/integrations/persisting-store-data.md @@ -575,7 +575,7 @@ const useBoundStore = create( { // ... onRehydrateStorage: (state) => { - state.setHasHydrated(true) + return () => state.setHasHydrated(true) } } )