Nuxt.js: Cannot access state from a store module using mapState

Created on 12 Aug 2018  路  5Comments  路  Source: nuxt/nuxt.js

Version

v1.4.2

Reproduction link

https://github.com/nuxt/nuxt.js/issues/3704

Steps to reproduce

\\ store/users.js 
export const state = () => ({
    user: 'Hello'
})
\\ pages/nav.vue 
<template>
    <div>  {{user}}   <div>
<template>



md5-52f80eb679cd20adb33e98fcfce71911


What is expected ?

mapState should access user state of users module

What is actually happening?

Property or method "user" is not defined on the instance but referenced during render

This bug report is available on Nuxt community (#c7551)

Most helpful comment

Try this instead:

...mapState({
  user: state => state.users.user
})

All 5 comments

Try this instead:

...mapState({
  user: state => state.users.user
})

It works well. Thanks

This question has been resolved by @paulgv, see answer.

Hello, I'm having the same problem with all the map helpers, and I would like to understand why that syntax works, and the one in the official documentation doesn't. What's the rationale?

EDIT:
I'm actually not able to use mapActions with that same syntax, how would it be?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings