I'm integrating NgXs Store into my app. I've created few simple states and trying to select data from them, but when app is launched I get the runtime error:
TypeError: Class constructor MyState cannot be invoked without 'new'
at ngxs-store.js:2166
at Array.map (<anonymous>)
at selectFromAppState (ngxs-store.js:2162)
at Store.selectSnapshot (ngxs-store.js:2343)
...
Finally I figured out that I forgot to supply the state class to NgxsModule
.
@NgModule({
imports: [
CommonModule,
NgxsModule.forRoot([
...
MyState // this line was missing, so the store cannot instantiate the state
], {
developmentMode: !environment.production
})
],
exports: [
NgxsModule
]
})
export class StoreModule {}