---
title: "Comment by Simo D. on \"How to use Zustand's persist middleware in Next.js\" | Hashnode"
description: "I tried this method but it caused my page to fall in a infinite loop due to the useEffect hook re-rendering the page every time the result variable changes and"
url: "https://hashnode.com/posts/how-to-use-zustands-persist-middleware-in-nextjs/640f4e685c1c3f8f90cb3705/comment/652b1d7e900df10a39260e2e"
---

[Discussion](https://hashnode.com/posts/how-to-use-zustands-persist-middleware-in-nextjs/640f4e685c1c3f8f90cb3705)

Comment [How to use Zustand's persist middleware in Next.js](https://hashnode.com/posts/how-to-use-zustands-persist-middleware-in-nextjs/640f4e685c1c3f8f90cb3705)

[Simo D.](https://hashnode.com/@simoooo)

[Oct 14, 2023](https://hashnode.com/posts/how-to-use-zustands-persist-middleware-in-nextjs/640f4e685c1c3f8f90cb3705/comment/652b1d7e900df10a39260e2e)

I tried this method but it caused my page to fall in a infinite loop due to the useEffect hook re-rendering the page every time the result variable changes and that same variable in used to set the state. any solution to this problem?

[Abdul Samad Ansari](https://hashnode.com/@abdulsamad-ansari)

[Oct 22, 2023](https://hashnode.com/posts/how-to-use-zustands-persist-middleware-in-nextjs/640f4e685c1c3f8f90cb3705/comment/652b1d7e900df10a39260e2e#reply-6534dd88aa602055e82fd9b7)

Hi Simo, The hook initially gives null and after that, the state is updated. I'm not sure why you're facing this problem. Please check the useEffect dependencies.
