vuex-typex icon indicating copy to clipboard operation
vuex-typex copied to clipboard

JS ERROR TypeError: undefined is not an object (evaluating '_this._store.rootGetters')

Open VannaDii opened this issue 6 years ago • 1 comments

Calling metrics.getMetricsDesc(); which is defined as:

import Vue from 'vue';
import Vuex, { Store } from 'vuex';
import { getStoreBuilder } from 'vuex-typex';
import { MetricsState } from './metricsState';

export interface RootState {
  metrics: MetricsState
}

Vue.use(Vuex);
const store: Store<RootState> = getStoreBuilder<RootState>().vuexStore();
export { store };
export default store;

import { RootState } from './store';
import { getStoreBuilder } from 'vuex-typex';

const initialMetricsState: MetricsState = {
    allMetrics: [],
    isLoading: false
}
const builder = getStoreBuilder<RootState>().module('metrics', initialMetricsState);
const metricsDesc = builder.read(state => state.allMetrics.sort((a, b) => (a.date > b.date ? -1 : 1)), 'metricsDesc');
const metrics = {
    // State
    get state() { return builder.state(); },

    // Getter as method
    getMetricsDesc() {
        return metricsDesc();
    },
}

VannaDii avatar Sep 03 '19 23:09 VannaDii

@GioCirque I ran into the same error, did you ever find out why you got this error?

zhangxinghao avatar Dec 04 '19 13:12 zhangxinghao