Open Pacheco95 opened 3 years ago
I'm trying to access data in my store inside my component, but the getter is being called before the created() method lifecycle hook and this is causing the problem TypeError: Cannot read property 'loading' of undefined
created()
TypeError: Cannot read property 'loading' of undefined
<template> <div class="container">{{ loading }}</div> </template> <script lang="ts"> import { Component, getModule, Vue } from "nuxt-property-decorator"; import ExampleStore from "~/store/example-store"; @Component export default class Hello extends Vue { exampleStore = getModule(ExampleStore, this.$store); get loading() { console.log("getter"); return this.exampleStore.loading; } created() { console.log("created?"); } } </script> <style> .container { margin: 0 auto; min-height: 100vh; display: flex; justify-content: center; align-items: center; text-align: center; } </style>
Reproductible code https://codesandbox.io/s/exciting-easley-e98j0?file=/pages/index.vue
I'm trying to access data in my store inside my component, but the getter is being called before the
created()
method lifecycle hook and this is causing the problemTypeError: Cannot read property 'loading' of undefined
Reproductible code https://codesandbox.io/s/exciting-easley-e98j0?file=/pages/index.vue