question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add more docs and examples for Persist middleware

See original GitHub issue

I think there should be examples to show how exactly to use the persist middleware configuration for a common use-case. For example, there is no way to know how to clear data from localStorage (or any persist mechanism), how to use the onRehydrateStorage for common use cases.

I am not sure if it has been discussed here but store first returns the initial state before fetching the state from storage, how to handle those situations?

Let me know your thoughts!

@dai-shi @AnatoleLucet

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
rohitpotatocommented, Feb 11, 2021

I was wondering if something like PersistGate was possible with zustand or maybe another approach out of the box?

There’s currently nothing like PersistGate, but it could be a nice feature to add. Though you could probably do something similar with another zustand store which could act as the gate.

I see, I think something like this can end up in the docs too. So people can implement their versions of Persist Gate.

2reactions
AnatoleLucetcommented, Feb 10, 2021

I was wondering if something like PersistGate was possible with zustand or maybe another approach out of the box?

There’s currently nothing like PersistGate, but it could be a nice feature to add. Though you could probably do something similar with another zustand store which could act as the gate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persist state with Redux Persist using Redux Toolkit in React
First, we'll add Redux Persist to our app with the following command: ... For example, to use the sessionStorage engine, we'll first import ......
Read more >
20 Developing Persistence in Applications Using Oracle ...
This chapter describes how to use the visual tools in JDeveloper to implement persistence using Oracle TopLink. You can configure TopLink descriptors and ......
Read more >
applyMiddleware - Redux
Another example of middleware is redux-promise. It lets you dispatch a Promise async action, and dispatches a normal action when the Promise ...
Read more >
Recipes - Zustand Documentation - Pmndrs.docs
For instance, if you want to construct a single object with multiple ... persist } from 'zustand/middleware' export const useStore = create( persist(...
Read more >
Creating React Apps With Redux Toolkit and RTK Query - Toptal
It includes detailed code examples ready for real-life scenarios. ... Next, we will add custom middleware for handling 401 responses by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found