Skip to content

How to access Zustand persist API? #45

Answered by zbeyens
vnugent asked this question in Q&A
Discussion options

You must be logged in to vote

The hook needs to be called outside useEffect, can you try this:

const store = userCollectionsStore.useStore()

useEffect(()=>{
  // do some check to see if we need to rehydrate store
  // @ts-expect-error
  store.persist.rehydrate()  // Error: Invalid hook call. 
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zbeyens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants