title: state not define in vue
body: <p>hello guys i follow everything provide no google but none of these working i m new to vuex 3.0.1 and vue 2.5 below of my code </p>
  
  <pre><code>import Vue from 'vue'
  import App from './App'
  import router from './router'
  import axios from 'axios'
  import store from './store'
  
  Vue.prototype.$http = axios;
  
  
   var VueResource = require('vue-resource');
   Vue.use(VueResource);
  
  
     router.beforeEach((to, from, next) =&gt; {
       console.log(this.$store.state.authUser)// this is not working
        if (to.matched.some(record =&gt; record.meta.requiresAuth) &amp;&amp; 
          (!this.$store.state.authUser || 
    this.$store.state.authUser === 'null')){
    const authUser = localStorage.getItem('authUser')
     console.log('here log');
     next({ path: '/', })
  
   }else{
     console.log('bhar else redirect');
    next()  
   }
  
  });
   new Vue({
     el: '#app',
      router,
      store,
     template: '&lt;App/&gt;',
  
      components: {
       App
       }
   })
  </code></pre>
  
  <p>everything work porperly if i remove this this.$store.state.authUser it work here is my store.js file</p>
  
  <pre><code>import Vue from 'vue'
   import Vuex from 'vuex'
   import userStore from './user/userStore.js'
   Vue.use(Vuex)
    const debug = process.env.NODE_ENV !== 'production'
  
   export default new Vuex.Store({
    modules:{
      userStore
    },
  
   strict:debug
   })
  </code></pre>
  
  <p>here is my userStore </p>
  
  <pre><code> const state = {
     authUser:null
      }
  const mutations  = {
      SET_AUTH_USER(state,userObj){
          state.authUser = userObj
          }
   }
     const actions = {
      setUserObject :({commit},userObj) =&gt;{
          commit('SET_AUTH_USER',userObj)
       }
     }
    export default {
        state, mutations, actions
   }
  </code></pre>
  
  <p>here is my login succcess from where i trie to dispatch value in store note i have value in store</p>
  
  <pre><code>  this.$store.dispatch('setUserObject',response.data.id)
  </code></pre>
  
  <p>i does everything properly but don't know why it throw error Cannot read property 'state' of undefined</p>