Is there anyway to access state in createJSONStorage? #2679
Unanswered
elson-currentcorp
asked this question in
General
Replies: 1 comment
-
That's not supported. It feels like a bad API design, but if you need it you might be able to create your own persist middleware. I'd suggest not using the middleware and use the store API after creating the store, which should be easier. const useFooStore = create(...);
// initialize from localStorage
useFooStore.setState(...);
// subscribe for adding an item to localStorage
useFooStore.subscribe(() => {
const state = useFooStore.getState();
...
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there anyway to access the set/get, store or state from within the
createJSONStorage
function? I want to implement something like the following:Beta Was this translation helpful? Give feedback.
All reactions