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.

How to persist the root state?

See original GitHub issue

I’m using modules but I also have some root state, so the object I pass to Vuex.Store looks like this:

{
  actions: {}
  getters: {}
  modules: {user: {…}, course: {…}, courses: {…}}
  mutations: {setNavFixed: ƒ, setTheme: ƒ}
  plugins: (2) [ƒ, ƒ]
  state: {…}
__proto__: Object
}

I want to persist the user module (which works fine) AND the root state.

The docs don’t mention how to do the latter.

Thanks!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jpcaparascommented, Nov 30, 2021

Sorry, late to the party, but to whoever is visiting this thread now, you can persist the root state by pushing a value of '/' to the modules array, e.g.

 plugins: [new VuexPersistence({
        modules: ['/'], 
    }).plugin],
0reactions
sustainedcommented, Sep 9, 2019

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persist state with Redux Persist using Redux Toolkit in React
We can customize a part of our state to persist by using the blacklist and whitelist properties of the config object passed to...
Read more >
Persist Redux State with redux-persist - DEV Community ‍ ‍
We can manually do the state persistent using the native JavaScript localStorage.setItem() method but honestly we will have to write ...
Read more >
The Definitive Guide to Redux Persist - React Native Coach
If you are using React, wrap your root component with PersistGate . This delays the rendering of your app's UI until your persisted...
Read more >
How to reset the state of a Redux store? - Stack Overflow
First, you need to import the appropriate storage engine and then, to parse the state before setting it to undefined and clean each...
Read more >
How to Persist Your Redux Store - How-To Geek
state, ...action}); const persistConfig = { key: "root", storage }; const persistedReducer = persistReducer(persistConfig, reducer); const store ...
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