Search code examples
angularngrxngrx-store

@ngrx/store computedStates[currentStateIndex] is undefined


I am currently learning about @ngrx/store and I am running into a strange situation that I need some help on.

I have created a simple store, with an inital value. I installed the Redux Devtools and that shows me the initialState:

{
  app: {
    products: {
      data: [
        {
        ...
        }
      ],
      loaded: false,
      loading: false
    }
  }
}

However, when I try to console.log that state I get this error:

TypeError: computedStates[currentStateIndex] is undefined

This is my code for logging the state:

  constructor(private store: Store<AppState>) { }

  ngOnInit(): void {
    this.store.select<any>('app').subscribe(state => console.log(state));
  }

Any pointers in the direction where I should be looking are welcome.

Update When I disable the StoreDevtoolsModule in my Module imports, the error disappears. This line:

StoreDevtoolsModule.instrument()

However, off course now the Redux Devtools don't work anymore! So, how can I get the application and the Devtools working?


Solution

  • You are running into an issue with Angular 5 and the Redux Devtools. It is currently under investigation here:

    https://github.com/ngrx/platform/issues/624

    The only confirmed workaround at the moment is downgrading to Angular 4.