Comments (3)
You are, in fact, able to get the value, since you are getting null which is the initial value you gave it. What you are not doing is updating this value. Furthermore, you are not really supposed to directly assign a value to a ref(), you assign to its .value
property inside a setter.
from pinia-plugin-persistedstate.
export const useInternationalStore = defineStore('international',
() => {
const currentLanguageCode = ref(null);
function setLang(value: string) {
currentLanguageCode.value = value;
}
return { currentLanguageCode, setLang }
}, { persist: true }
)
in someMethod:
const internationalStore = useInternationalStore()
internationalStore.setLang('en')
from pinia-plugin-persistedstate.
See #221
from pinia-plugin-persistedstate.
Related Issues (20)
- Using store outside setup(), state persistence is not possible HOT 1
- The type of map print in console.log (typeof this.userMap) is object HOT 1
- Persist for "composition api" style HOT 1
- 配置 storage: persistedState.sessionStorage 会导致 v-bind 失效
- Vue: Argument of type HOT 2
- when to persist and when to recover HOT 1
- How to Securely store an object in local storage without storing It as plain object? HOT 5
- not able to use persistence in plugins created from user modules HOT 1
- Sync with redis HOT 5
- default storage to persistedState.localStorage HOT 6
- Does not work properly in vue3 HOT 5
- Typescript error when defining global options HOT 4
- Global auto persist config option in nuxt.conf.ts HOT 1
- How to import this library through CDN? HOT 2
- Nuxt3使用pinia-plugin-persistedstate/nuxt不生效 HOT 7
- Nuxt3 'persist' does not exist in type 'DefineStoreOptions' HOT 2
- Hydration completed but contains mismatches.
- can not work normally HOT 3
- Update cookiesWithOptions HOT 1
- why i can't import in nuxt3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinia-plugin-persistedstate.