Pinia state undefined in vue dev tools
See original GitHub issueReproduction
Yes
Steps to reproduce the bug
Defined store with following:
import { defineStore } from 'pinia';
export const useUsersStore = defineStore({
id: 'user',
state: (): UserState => ({
user: {} as User,
}),
getters: {
token: (state) => state.user.token,
},
actions: {
async addUserToken(token: string | null) {
this.user = { token: token };
},
},
});
Access the store in component
const usersStore = useUsersStore();
const { user } = storeToRefs(usersStore);
Open dev tools
Expected behavior
I expect the store state to be visible in the dev tools.
Actual behavior
The _custom object contains the values, however it doesn’t look like it works as expected.
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
vue.js - Vue3.js and Pinia: Why is my store state undefined in ...
I found a away to solve it, though I think its not perfect // should use computed const languages = computed(() => languageStore.languages ......
Read more >State | Pinia
The state is, most of the time, the central part of your store. People often start by defining the state that represents their...
Read more >"Cannot read properties of undefined" error in simple pinia store.
Getting a "Cannot read properties of undefined (reading settings)" error in the console. Not sure why. The getter if working just fine.
Read more >Complex Vue 3 state management made easy with Pinia
Build a basic blog engine using Pinia, a state management tool for Vue apps, and its main features, including state, getters, and actions....
Read more >Why is Vue DevTools displaying Pinia getters like this?
To cut to the chase, if I look under "computed" in Vue DevTools for store ... the in the Pinia tab of DevTools,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
On a side note, the property of a state also becomes undefined when you a) use a getter method has the same name as one of the props defined in the state, b) use async modifier at the state definition, like so:
async state: () => { let userId = await axios.get('urlToMyFancyUserService') return { id: userId } },
@posva The reproduction is posted in my previous comment. Is it sufficient?