Zustand can save functions in store? #1203
-
(Please understand that the expression may not be appropriate using a translator.) Can I use the function by storing it in the store? It may be a basic question, but even if I save the function and use it, there is no error, so I ask if it is a usable pattern! For example, we are going to save the onClick callback and use it when injecting an event to the component to be rendered according to the list state of the store! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yes, you can store functions. In fact, actions are functions put in a store. Notice, there might be something unexpected/undesired depending on the usage, but from zustand point of view, it's possible. |
Beta Was this translation helpful? Give feedback.
-
ah! There was a separate question channel, sorry
In case the explanation is not enough, I will write additionally how the data will be entered. Would it be ok to save it as it is? Sorry to keep asking. |
Beta Was this translation helpful? Give feedback.
Yes, you can store functions. In fact, actions are functions put in a store.
Notice, there might be something unexpected/undesired depending on the usage, but from zustand point of view, it's possible.