[nuxt] state should be a function in store/index.js

yinshipeng
0
yinshipeng
commented 2 years ago

nuxt error

0
promek
25
promek
commented 2 years ago

Try changing the state variable in the store/index.js file as follows.

export const state = () => ({
user: null
})

5
IamManchanda
0
IamManchanda
commented 2 years ago

@promek thanks ;)

0
piiwa
0
piiwa
commented 2 years ago

Solved, thks @promek
Why is it happening ?

0
klaveren
0
klaveren
commented 2 years ago

Solved too, thank you.

0
leoyli
0
leoyli
commented a year ago

Hi, just wonder why the core team choosing to export state as a function rather than an object? It seems counterintuitive since the state is indeed an object in vuex though…

0
Informations
QuestionUnresolved
#c14 - Created 2 years ago