Persist Middleware | Wait for store to be hydrated but only return once #2531
-
Hello community. I'm struggling to avoid certain re-renders in my application using the persist middleware. One of the things I noticed is that after the store is hydrated from localstorage a new render takes place. In my particular case I only need the "initial hydrated" values only once to initialize a form and even though the values I request change during the wizard I only need them for the initial load.
In this case
Adding this amount of code just to avoid a couple of re-renders seems overkill but I wanted to try and understand why it's not updated only once after store hydrated. Thanks in advance. Stack: NextJS 14 Zustand 4.5.2 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@agustingabiola here you go -> https://stackblitz.com/edit/nextjs-and-zustand-persist?file=README.md btw, there's no way to avoid the loading state |
Beta Was this translation helpful? Give feedback.
@agustingabiola here you go -> https://stackblitz.com/edit/nextjs-and-zustand-persist?file=README.md btw, there's no way to avoid the loading state