actions returns a error : not a function #2026
-
hi, first sorry my bad english I'm Braziliam. I'm having problems using the persist/middleware, I'm using zustent + nextjs 13 (app folder), and I need to persist the data. When using the persist, I receive the data correctly from the state, but when I try to use the functions inside the action I get the error: is not a function. I know it must be a stupid error but I don't know what to do, nothing I've tried has helped, can anyone help me? Here is the code for my store (PS: I'm using the custom hook to get the state as in the zustand docs)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
edit : I moved my functions to the same level as the 'states' object and things started working again. Why? I would like to keep things as they are, separated by objects. Is it possible? |
Beta Was this translation helpful? Give feedback.
@RaffDv in a nutshell you are persisting actions too, in order to make it work you need to use
partialize: ({ state }) => ({ state })