How to clear state on route change ?
Unanswered
Lionhead posted this in #help-forum
LionheadOP
I am using latest version of next.js app router and i have a client component where I am using zustand for state management and when i am interacting and setting some state and navigate to other page and come back to same page the state is persisted. I don't want that is there any solution for that.
I am using Next.js <Link> component for nav links btw.
And also I am using normal zustand not persist middleware to store it in localStorage.
Of course i can use useEffect to clear the state on render but is there any other better solution.
I am using Next.js <Link> component for nav links btw.
And also I am using normal zustand not persist middleware to store it in localStorage.
Of course i can use useEffect to clear the state on render but is there any other better solution.